#!/usr/bin/env python
#
# Generate Actions from AWS static configuration
#
import json
import os
try:
    from urllib2 import urlopen
except ImportError:
    from urllib.request import urlopen
from slimit.parser import Parser
from slimit.visitors import nodevisitor
from slimit.visitors.ecmavisitor import ECMAVisitor
from slimit import ast


header = """\
# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>
# All rights reserved.
#
# See LICENSE file for full license.

from aws import Action as BaseAction
from aws import BaseARN
"""

extra_classes = """\
class Action(BaseAction):
    def __init__(self, action=None):
        sup = super(Action, self)
        sup.__init__(prefix, action)


class ARN(BaseARN):
    def __init__(self, resource='', region='', account=''):
        sup = super(ARN, self)
        sup.__init__(service=prefix, resource=resource, region=region,
                     account=account)
"""

extra_classes_s3 = """\
class Action(BaseAction):
    def __init__(self, action=None):
        sup = super(Action, self)
        sup.__init__(prefix, action)


class ARN(BaseARN):
    def __init__(self, resource='', region='', account=''):
        sup = super(ARN, self)
        # account is empty for S3
        account = ''
        sup.__init__(service=prefix, resource=resource, region=region,
                     account=account)
"""

arn = """\
class %(upper)s_ARN(ARN):
    def __init__(self, *args, **kwargs):
        super(%(upper)s_ARN, self).__init__(*args, **kwargs)
        warnings.warn("This class is going away. Use %(lower)s.ARN instead.",
                      FutureWarning)
"""

legacy_arns = ['iam', 's3', 'sdb', 'sns', 'sqs']

aws_url = \
    "https://awsiamconsole.s3.amazonaws.com/iam/assets/js/bundles/policies.js"

basedir = 'generated'

response = urlopen(aws_url)
config = response.read()


class JSONVisitor(ECMAVisitor):
    def visit_Identifier(self, node):
        return '"%s"' % node.value

    def visit_Number(self, node):
        return '"%s"' % node.value

    def visit_UnaryOp(self, node):
        s = self.visit(node.value)
        if node.op == '!' and s == 0:
            return '"true"'
        else:
            return s


visitor = JSONVisitor()
parser = Parser()
tree = parser.parse(config.decode('utf-8'))

flag = False
policy_editor_config = ""
for node in nodevisitor.visit(tree):
    if (isinstance(node, ast.Identifier) and
            node.value == 'PolicyEditorConfig'):
        flag = True
    elif flag:
        policy_editor_config = visitor.visit(node)
        break

d = json.loads(policy_editor_config)

try:
    os.mkdir(basedir)
except OSError:
    pass


# Extra services are for those not advertised in policies.js,
# but are available to be called via AWS apis. If/When these
# services are added to policies.js, the entry in extra_services
# will be ignored. IE, policies.js takes priority over
# extra_services entries.

extra_services = {
    'AWS Accounts': {
        'StringPrefix': 'account',
        'Actions': [
            'DisableRegion',
            'EnableRegion',
            'ListRegions',
        ],
    },
    'AWS Certificate Manager Private Certificate Authority': {
        'StringPrefix': 'acm-pca',
        'Actions': [
            'CreateCertificateAuthority',
            'CreateCertificateAuthorityAuditReport',
            'CreatePermission',
            'DeleteCertificateAuthority',
            'DeletePermission',
            'DescribeCertificateAuthority',
            'DescribeCertificateAuthorityAuditReport',
            'GetCertificate',
            'GetCertificateAuthorityCertificate',
            'GetCertificateAuthorityCsr',
            'ImportCertificateAuthorityCertificate',
            'IssueCertificate',
            'ListCertificateAuthorities',
            'ListPermissions',
            'ListTags',
            'RestoreCertificateAuthority',
            'RevokeCertificate',
            'TagCertificateAuthority',
            'UntagCertificateAuthority',
            'UpdateCertificateAuthority',
        ],
    },
    'AWS Amplify': {
        'StringPrefix': 'amplify',
        'Actions': [
            'CreateApp',
            'CreateBranch',
            'CreateDomainAssociation',
            'DeleteApp',
            'DeleteBranch',
            'DeleteDomainAssociation',
            'DeleteJob',
            'GetApp',
            'GetBranch',
            'GetDomainAssociation',
            'GetJob',
            'ListApps',
            'ListBranches',
            'ListDomainAssociations',
            'ListJobs',
            'StartJob',
            'StopJob',
            'UpdateApp',
            'UpdateBranch',
            'UpdateDomainAssociation',
        ],
    },
    'AWS App Mesh': {
        'StringPrefix': 'appmesh',
        'Actions': [
            'CreateMesh',
            'CreateRoute',
            'CreateVirtualNode',
            'CreateVirtualRouter',
            'CreateVirtualService',
            'DeleteMesh',
            'DeleteRoute',
            'DeleteVirtualNode',
            'DeleteVirtualRouter',
            'DeleteVirtualService',
            'DescribeMesh',
            'DescribeRoute',
            'DescribeVirtualNode',
            'DescribeVirtualRouter',
            'DescribeVirtualService',
            'ListMeshes',
            'ListRoutes',
            'ListTagsForResource',
            'ListVirtualNodes',
            'ListVirtualRouters',
            'ListVirtualServices',
            'TagResource',
            'UntagResource',
            'UpdateMesh',
            'UpdateRoute',
            'UpdateVirtualNode',
            'UpdateVirtualRouter',
            'UpdateVirtualService',
        ],
    },
    'AWS Backup': {
        'StringPrefix': 'backup',
        'Actions': [
            'CreateBackupPlan',
            'CreateBackupSelection',
            'CreateBackupVault',
            'DeleteBackupPlan',
            'DeleteBackupSelection',
            'DeleteBackupVault',
            'DeleteBackupVaultAccessPolicy',
            'DeleteBackupVaultNotifications',
            'DeleteRecoveryPoint',
            'DescribeBackupJob',
            'DescribeBackupVault',
            'DescribeProtectedResource',
            'DescribeRecoveryPoint',
            'DescribeRestoreJob',
            'ExportBackupPlanTemplate',
            'GetBackupPlan',
            'GetBackupPlanFromJSON',
            'GetBackupPlanFromTemplate',
            'GetBackupSelection',
            'GetBackupVaultAccessPolicy',
            'GetBackupVaultNotifications',
            'GetRecoveryPointRestoreMetadata',
            'GetSupportedResourceTypes',
            'ListBackupJobs',
            'ListBackupPlanTemplates',
            'ListBackupPlanVersions',
            'ListBackupPlans',
            'ListBackupSelections',
            'ListBackupVaults',
            'ListProtectedResources',
            'ListRecoveryPointsByBackupVault',
            'ListRecoveryPointsByResource',
            'ListRestoreJobs',
            'ListTags',
            'PutBackupVaultAccessPolicy',
            'PutBackupVaultNotifications',
            'StartBackupJob',
            'StartRestoreJob',
            'StopBackupJob',
            'TagResource',
            'UntagResource',
            'UpdateBackupPlan',
            'UpdateRecoveryPointLifecycle',
        ],
    },
    'Comprehend Medical': {
        'StringPrefix': 'comprehendmedical',
        'Actions': [
            'DetectEntities',
            'DetectPHI',
        ],
    },
    'DataSync': {
        'StringPrefix': 'datasync',
        'Actions': [
            'CancelTaskExecution',
            'CreateAgent',
            'CreateLocationEfs',
            'CreateLocationNfs',
            'CreateLocationS3',
            'CreateTask',
            'DeleteAgent',
            'DeleteLocation',
            'DeleteTask',
            'DescribeAgent',
            'DescribeLocationEfs',
            'DescribeLocationNfs',
            'DescribeLocationS3',
            'DescribeTask',
            'DescribeTaskExecution',
            'ListAgents',
            'ListLocations',
            'ListTagsForResource',
            'ListTaskExecutions',
            'ListTasks',
            'StartTaskExecution',
            'TagResource',
            'UntagResource',
            'UpdateAgent',
            'UpdateTask',
        ],
    },
    'AWS DeepLens': {
        'StringPrefix': 'deeplens',
        'Actions': [
            'AssociateServiceRoleToAccount',
            'BatchGetDevice',
            'BatchGetModel',
            'BatchGetProject',
            'CreateDeviceCertificates',
            'CreateModel',
            'CreateProject',
            'DeleteModel',
            'DeleteProject',
            'DeployProject',
            'DeregisterDevice',
            'GetAssociatedResources',
            'GetDeploymentStatus',
            'GetDevice',
            'GetModel',
            'GetProject',
            'ImportProjectFromTemplate',
            'ListDeployments',
            'ListDevices',
            'ListModels',
            'ListProjects',
            'RegisterDevice',
            'RemoveProject',
            'UpdateProject',
        ],
    },
    'Amazon Data Lifecycle Manager': {
        'StringPrefix': 'dlm',
        'Actions': [
            'CreateLifecyclePolicy',
            'DeleteLifecyclePolicy',
            'GetLifecyclePolicies',
            'GetLifecyclePolicy',
            'UpdateLifecyclePolicy',
        ],
    },
    'Amazon Elastic Container Service for Kubernetes': {
        'StringPrefix': 'eks',
        'Actions': [
            'CreateCluster',
            'DeleteCluster',
            'DescribeCluster',
            'DescribeUpdate',
            'ListClusters',
            'ListUpdates',
            'UpdateClusterVersion',
        ],
    },
    'Amazon Elastic Inference': {
        'StringPrefix': 'elastic-inference',
        'Actions': [
            'Connect',
        ],
    },
    'AWS Firewall Manager': {
        'StringPrefix': 'fms',
        'Actions': [
            'AssociateAdminAccount',
            'DeleteNotificationChannel',
            'DeletePolicy',
            'DisassociateAdminAccount',
            'GetAdminAccount',
            'GetComplianceDetail',
            'GetNotificationChannel',
            'GetPolicy',
            'GetProtectionStatus',
            'ListComplianceStatus',
            'ListMemberAccounts',
            'ListPolicies',
            'PutNotificationChannel',
            'PutPolicy',
        ],
    },
    'Amazon FSx': {
        'StringPrefix': 'fsx',
        'Actions': [
            'CreateBackup',
            'CreateFileSystem',
            'CreateFileSystemFromBackup',
            'DeleteBackup',
            'DeleteFileSystem',
            'DescribeBackups',
            'DescribeFileSystems',
            'ListTagsForResource',
            'TagResource',
            'UntagResource',
            'UpdateFileSystem',
        ],
    },
    'Global Accelerator': {
        'StringPrefix': 'globalaccelerator',
        'Actions': [
            'CreateAccelerator',
            'CreateEndpointGroup',
            'CreateListener',
            'DeleteAccelerator',
            'DeleteEndpointGroup',
            'DeleteListener',
            'DescribeAccelerator',
            'DescribeAcceleratorAttributes',
            'DescribeEndpointGroup',
            'DescribeListener',
            'ListAccelerators',
            'ListEndpointGroups',
            'ListListeners',
            'UpdateAccelerator',
            'UpdateAcceleratorAttributes',
            'UpdateEndpointGroup',
            'UpdateListener',
        ],
    },
    'Amazon GroundTruth Labeling': {
        'StringPrefix': 'groundtruthlabeling',
        'Actions': [
            'DescribeConsoleJob',
            'ListDatasetObjects',
            'RunFilterOrSampleDatasetJob',
            'RunGenerateManifestByCrawlingJob',
        ],
    },
    'AWS IoT 1-Click': {
        'StringPrefix': 'iot1click',
        'Actions': [
            'AssociateDeviceWithPlacement',
            'ClaimDevicesByClaimCode',
            'CreatePlacement',
            'CreateProject',
            'DeletePlacement',
            'DeleteProject',
            'DescribeDevice',
            'DescribePlacement',
            'DescribeProject',
            'DisassociateDeviceFromPlacement',
            'FinalizeDeviceClaim',
            'GetDeviceMethods',
            'GetDevicesInPlacement',
            'InitializeDeviceClaim',
            'InitiateDeviceClaim',
            'InvokeDeviceMethod',
            'ListDeviceEvents',
            'ListDevices',
            'ListPlacements',
            'ListProjects',
            'ListTagsForResource',
            'TagResource',
            'UnclaimDevice',
            'UntagResource',
            'UpdateDeviceState',
            'UpdatePlacement',
            'UpdateProject',
        ],
    },
    'AWS IoT Events': {
        'StringPrefix': 'iotevents',
        'Actions': [
            'BatchPutMessage',
            'CreateDetectorModel',
            'CreateInput',
            'DeleteDetectorModel',
            'DeleteInput',
            'DescribeDetector',
            'DescribeDetectorModel',
            'DescribeInput',
            'DescribeLoggingOptions',
            'ListDetectorModelVersions',
            'ListDetectorModels',
            'ListDetectors',
            'ListInputs',
            'PutLoggingOptions',
            'UpdateDetectorModel',
            'UpdateInput',
        ],
    },
    'AWS IoT SiteWise': {
        'StringPrefix': 'iotsitewise',
        'Actions': [
            'AssociateGatewaySink',
            'AssociateGatewaySource',
            'AssociateViewEntities',
            'CreateAsset',
            'CreateAssetTemplate',
            'CreateGateway',
            'CreateGroup',
            'CreateMeasurementDataStore',
            'CreateMetricType',
            'CreateView',
            'DeleteAsset',
            'DeleteAssetTemplate',
            'DeleteGateway',
            'DeleteGroup',
            'DeleteMeasurementDataStore',
            'DeleteMetricType',
            'DeleteView',
            'DeregisterViewEntities',
            'DescribeAssetTemplates',
            'DescribeAssets',
            'DescribeGateways',
            'DescribeGroups',
            'DescribeMeasurementDataStores',
            'DescribeMetricTypes',
            'DescribeViews',
            'DisassociateGatewaySink',
            'DisassociateGatewaySource',
            'DisassociateViewEntities',
            'GetMeasurementData',
            'GetMetricData',
            'ListAssetTemplates',
            'ListAssets',
            'ListGateways',
            'ListGroups',
            'ListMeasurementDataStores',
            'ListMeasurementDataStreams',
            'ListMetricTypes',
            'ListViewEntities',
            'ListViews',
            'RegisterViewEntities',
            'UpdateAsset',
            'UpdateAssetTemplate',
            'UpdateGateway',
            'UpdateGroup',
            'UpdateMeasurementDataStore',
            'UpdateView',
        ],
    },
    'Amazon Managed Streaming for Kafka': {
        'StringPrefix': 'kafka',
        'Actions': [
            'CreateCluster',
            'DeleteCluster',
            'DescribeCluster',
            'GetBootstrapBrokers',
            'ListClusters',
            'ListNodes',
        ],
    },
    'Amazon Kinesis Analytics V2': {
        'StringPrefix': 'kinesisanalytics',
        'Actions': [
            # V1 and V2 share the same prefix.  To avoid duplicates in
            # kinesisanalytics.py, actions that are available in both
            # versions are commented out in this list.
            'AddApplicationCloudWatchLoggingOption',
            # 'AddApplicationInput',
            'AddApplicationInputProcessingConfiguration',
            # 'AddApplicationOutput',
            # 'AddApplicationReferenceDataSource',
            # 'CreateApplication',
            'CreateApplicationSnapshot',
            # 'DeleteApplication',
            'DeleteApplicationCloudWatchLoggingOption',
            'DeleteApplicationInputProcessingConfiguration',
            # 'DeleteApplicationOutput',
            # 'DeleteApplicationReferenceDataSource',
            'DeleteApplicationSnapshot',
            # 'DescribeApplication',
            'DescribeApplicationSnapshot',
            # 'DiscoverInputSchema',
            'ListApplicationSnapshots',
            # 'ListApplications',
            # 'StartApplication',
            # 'StopApplication',
            # 'UpdateApplication',
        ],
    },
    'AWS License Manager': {
        'StringPrefix': 'license-manager',
        'Actions': [
            'CreateLicenseConfiguration',
            'DeleteLicenseConfiguration',
            'GetLicenseConfiguration',
            'GetServiceSettings',
            'ListAssociationsForLicenseConfiguration',
            'ListLicenseConfigurations',
            'ListLicenseSpecificationsForResource',
            'ListResourceInventory',
            'ListTagsForResource',
            'ListUsageForLicenseConfiguration',
            'TagResource',
            'UntagResource',
            'UpdateLicenseConfiguration',
            'UpdateLicenseSpecificationsForResource',
            'UpdateServiceSettings',
        ],
    },
    'Amazon Macie': {
        'StringPrefix': 'macie',
        'Actions': [
            'AssociateMemberAccount',
            'AssociateS3Resources',
            'DisassociateMemberAccount',
            'DisassociateS3Resources',
            'ListMemberAccounts',
            'ListS3Resources',
            'UpdateS3Resources',
        ],
    },
    'Amazon Managed Blockchain': {
        'StringPrefix': 'managedblockchain',
        'Actions': [
            'CreateMember',
            'CreateNetwork',
            'CreateNode',
            'CreateProposal',
            'DeleteMember',
            'DeleteNode',
            'GetMember',
            'GetNetwork',
            'GetNode',
            'GetProposal',
            'ListInvitations',
            'ListMembers',
            'ListNetworks',
            'ListNodes',
            'ListProposalVotes',
            'ListProposals',
            'RejectInvitation',
            'VoteOnProposal',
        ],
    },
    'AWS Elemental MediaConnect': {
        'StringPrefix': 'mediaconnect',
        'Actions': [
            'AddFlowOutputs',
            'CreateFlow',
            'DeleteFlow',
            'DescribeFlow',
            'GrantFlowEntitlements',
            'ListEntitlements',
            'ListFlows',
            'RemoveFlowOutput',
            'RevokeFlowEntitlement',
            'StartFlow',
            'StopFlow',
            'UpdateFlowEntitlement',
            'UpdateFlowOutput',
            'UpdateFlowSource',
        ],
    },
    'AWS Elemental MediaTailor': {
        'StringPrefix': 'mediatailor',
        'Actions': [
            'DeletePlaybackConfiguration',
            'GetPlaybackConfiguration',
            'ListPlaybackConfigurations',
            'ListTagsForResource',
            'PutPlaybackConfiguration',
            'TagResource',
            'UntagResource',
        ],
    },
    'Amazon Neptune': {
        'StringPrefix': 'neptune-db',
        'Actions': [
            'connect',
        ],
    },
    'AWS Performance Insights': {
        'StringPrefix': 'pi',
        'Actions': [
            'DescribeDimensionKeys',
            'GetResourceMetrics',
        ],
    },
    'QuickSight': {
        'StringPrefix': 'quicksight',
        'Actions': [
            'ListGroupMemberships', 'ListGroups', 'ListUserGroups',
            'ListUsers', 'DescribeGroup', 'DescribeUser', 'CreateAdmin',
            'CreateGroup', 'CreateGroupMembership', 'CreateReader',
            'CreateUser', 'DeleteGroup', 'DeleteGroupMembership',
            'DeleteUser', 'GetDashboardEmbedUrl', 'GetGroupMapping',
            'RegisterUser', 'SearchDirectoryGroups', 'SetGroupMapping',
            'Subscribe', 'Unsubscribe', 'UpdateGroup',
            'DeleteUserByPrincipalId',
            'UpdateUser',
        ]
    },
    'AWS Resource Access Manager': {
        'StringPrefix': 'ram',
        'Actions': [
            'AcceptResourceShareInvitation',
            'AssociateResourceShare',
            'CreateResourceShare',
            'DeleteResourceShare',
            'DisassociateResourceShare',
            'EnableSharingWithAwsOrganization',
            'GetResourcePolicies',
            'GetResourceShareAssociations',
            'GetResourceShareInvitations',
            'GetResourceShares',
            'ListPrincipals',
            'ListResources',
            'RejectResourceShareInvitation',
            'TagResource',
            'UntagResource',
            'UpdateResourceShare',
        ],
    },
    'AWS RoboMaker': {
        'StringPrefix': 'robomaker',
        'Actions': [
            'BatchDescribeSimulationJob',
            'CancelSimulationJob',
            'CreateDeploymentJob',
            'CreateFleet',
            'CreateRobot',
            'CreateRobotApplication',
            'CreateRobotApplicationVersion',
            'CreateSimulationApplication',
            'CreateSimulationApplicationVersion',
            'CreateSimulationJob',
            'DeleteRobot',
            'DeleteRobotApplication',
            'DeleteSimulationApplication',
            'DeregisterRobot',
            'DescribeDeploymentJob',
            'DescribeFleet',
            'DescribeRobot',
            'DescribeRobotApplication',
            'DescribeSimulationApplication',
            'DescribeSimulationJob',
            'ListDeploymentJobs',
            'ListFleets',
            'ListRobotApplications',
            'ListRobots',
            'ListSimulationApplications',
            'ListSimulationJobs',
            'RegisterRobot',
            'RestartSimulationJob',
            'SyncDeploymentJob',
            'UpdateRobotApplication',
            'UpdateSimulationApplication',
        ],
    },
    'Amazon Route 53 Resolver': {
        'StringPrefix': 'route53resolver',
        'Actions': [
            'AssociateResolverEndpointIpAddress',
            'AssociateResolverRule',
            'CreateResolverEndpoint',
            'CreateResolverRule',
            'DeleteResolverEndpoint',
            'DeleteResolverRule',
            'DisassociateResolverEndpointIpAddress',
            'DisassociateResolverRule',
            'GetResolverEndpoint',
            'GetResolverRule',
            'GetResolverRuleAssociation',
            'GetResolverRulePolicy',
            'ListResolverEndpointIpAddresses',
            'ListResolverEndpoints',
            'ListResolverRuleAssociations',
            'ListResolverRules',
            'ListTagsForResource',
            'PutResolverRulePolicy',
            'TagResource',
            'UntagResource',
            'UpdateResolverEndpoint',
            'UpdateResolverRule',
        ],
    },
    'AWS Secrets Manager': {
        'ARNFormat': 'arn:aws:secretsmanager:'
                     '<region>:<account>'
                     ':secret:<resourceType>/<resourcePath>',
        'ARNRegex': '^arn:aws:secretsmanager:.+',
        'Actions': [
            'CancelRotateSecret', 'CreateSecret', 'DeleteResourcePolicy',
            'DeleteSecret', 'DescribeSecret', 'GetRandomPassword',
            'GetResourcePolicy', 'GetSecretValue', 'ListSecrets',
            'ListSecretVersionIds', 'PutResourcePolicy',
            'PutSecretValue', 'RestoreSecret', 'RotateSecret',
            'TagResource', 'UntagResource', 'UpdateSecret',
            'UpdateSecretVersionStage'
        ],
        'HasResource': '!0',
        'StringPrefix': 'secretsmanager',
        'conditionKeys': [
            'secretsmanager:Resource/AllowRotationLambdaArn',
            'secretsmanager:Description',
            'secretsmanager:ForceDeleteWithoutRecovery',
            'secretsmanager:KmsKeyId',
            'secretsmanager:Name',
            'secretsmanager:RecoveryWindowInDays',
            'secretsmanager:ResourceTag/<tagname>',
            'secretsmanager:RotationLambdaArn',
            'secretsmanager:SecretId',
            'secretsmanager:VersionId',
            'secretsmanager:VersionStage'
        ],
    },
    'AWS Security Hub': {
        'StringPrefix': 'securityhub',
        'Actions': [
            'AcceptInvitation',
            'BatchDisableStandards',
            'BatchEnableStandards',
            'BatchImportFindings',
            'CreateInsight',
            'CreateMembers',
            'DeclineInvitations',
            'DeleteInsight',
            'DeleteInvitations',
            'DeleteMembers',
            'DisableImportFindingsForProduct',
            'DisableSecurityHub',
            'DisassociateFromMasterAccount',
            'DisassociateMembers',
            'EnableImportFindingsForProduct',
            'EnableSecurityHub',
            'GetEnabledStandards',
            'GetFindings',
            'GetInsightResults',
            'GetInsights',
            'GetInvitationsCount',
            'GetMasterAccount',
            'GetMembers',
            'InviteMembers',
            'ListEnabledProductsForImport',
            'ListInvitations',
            'ListMembers',
            'UpdateFindings',
            'UpdateInsight',
        ],
    },
    'AWS Server Migration Service': {
        'StringPrefix': 'sms',
        'Actions': [
            'CreateApp',
            'CreateReplicationJob',
            'DeleteApp',
            'DeleteAppLaunchConfiguration',
            'DeleteAppReplicationConfiguration',
            'DeleteReplicationJob',
            'DeleteServerCatalog',
            'DisassociateConnectors',
            'GenerateChangeSet',
            'GenerateTemplate',
            'GetApp',
            'GetAppLaunchConfiguration',
            'GetAppReplicationConfiguration',
            'GetConnectors',
            'GetReplicationJobs',
            'GetReplicationRuns',
            'GetServers',
            'ImportServerCatalog',
            'LaunchApp',
            'ListApps',
            'PutAppLaunchConfiguration',
            'PutAppReplicationConfiguration',
            'StartAppReplication',
            'StartOnDemandReplicationRun',
            'StopAppReplication',
            'TerminateApp',
            'UpdateApp',
            'UpdateReplicationJob',
        ],
    },
    'Amazon Pinpoint SMS and Voice Service': {
        'StringPrefix': 'sms-voice',
        'Actions': [
            'CreateConfigurationSet',
            'CreateConfigurationSetEventDestination',
            'DeleteConfigurationSet',
            'DeleteConfigurationSetEventDestination',
            'GetConfigurationSetEventDestinations',
            'ListConfigurationSets',
            'SendVoiceMessage',
            'UpdateConfigurationSetEventDestination',
        ],
    },
    'SMM Messages': {
        'StringPrefix': 'ssmmessages',
        'Actions': [
            'CreateControlChannel',
            'CreateDataChannel',
            'OpenControlChannel',
            'OpenDataChannel',
        ],
    },
    'AWS SSO Directory': {
        'StringPrefix': 'sso-directory',
        'Actions': [
            'AddMemberToGroup',
            'CreateAlias',
            'CreateGroup',
            'CreateUser',
            'DeleteGroup',
            'DeleteUser',
            'DescribeDirectory',
            'DescribeGroups',
            'DescribeUsers',
            'DisableUser',
            'EnableUser',
            'ListGroupsForUser',
            'ListMembersInGroup',
            'RemoveMemberFromGroup',
            'UpdateGroup',
            'UpdatePassword',
            'UpdateUser',
            'VerifyEmail',
        ],
    },
    'Amazon Sumerian': {
        'StringPrefix': 'sumerian',
        'Actions': [
            'Login',
            'ViewRelease',
        ],
    },
    'Amazon Textract': {
        'StringPrefix': 'textract',
        'Actions': [
            'AnalyzeDocument',
            'DetectDocumentText',
            'GetDocumentAnalysis',
            'GetDocumentTextDetection',
            'StartDocumentAnalysis',
            'StartDocumentTextDetection',
        ],
    },
    'AWS Transfer for SFTP': {
        'StringPrefix': 'transfer',
        'Actions': [
            'CreateServer',
            'CreateUser',
            'DeleteServer',
            'DeleteSshPublicKey',
            'DeleteUser',
            'DescribeServer',
            'DescribeUser',
            'ImportSshPublicKey',
            'ListServers',
            'ListTagsForResource',
            'ListUsers',
            'StartServer',
            'StopServer',
            'TagResource',
            'TestIdentityProvider',
            'UntagResource',
            'UpdateServer',
            'UpdateUser',
        ],
    },
    'AWS Well-Architected Tool': {
        'StringPrefix': 'wellarchitected',
        'Actions': [
            'CreateWorkload',
            'GetWorkload',
            'ListWorkloads',
        ],
    },
    'Amazon WorkLink': {
        'StringPrefix': 'worklink',
        'Actions': [
            'AssociateWebsiteCertificateAuthority',
            'CreateFleet',
            'DeleteFleet',
            'DescribeCompanyNetworkConfiguration',
            'DescribeDevice',
            'DescribeDevicePolicyConfiguration',
            'DescribeFleetMetadata',
            'DescribeIdentityProviderConfiguration',
            'DescribeWebsiteCertificateAuthority',
            'DisassociateWebsiteCertificateAuthority',
            'ListDevices',
            'ListFleets',
            'ListWebsiteCertificateAuthorities',
            'SignOutUser',
            'UpdateCompanyNetworkConfiguration',
            'UpdateDevicePolicyConfiguration',
            'UpdateFleetMetadata',
            'UpdateIdentityProviderConfiguration',
        ],
    },
}


extra_actions = {
    'a4b': [
        'ApproveSkill',
        'AssociateContactWithAddressBook',
        'AssociateSkillWithSkillGroup',
        'AssociateSkillWithUsers',
        'CreateAddressBook',
        'CreateBusinessReportSchedule',
        'CreateConferenceProvider',
        'CreateContact',
        'DeleteAddressBook',
        'DeleteBusinessReportSchedule',
        'DeleteConferenceProvider',
        'DeleteContact',
        'DeleteDevice',
        'DeleteSkillAuthorization',
        'DisassociateContactFromAddressBook',
        'DisassociateSkillFromSkillGroup',
        'DisassociateSkillFromUsers',
        'ForgetSmartHomeAppliances',
        'GetAddressBook',
        'GetConferencePreference',
        'GetConferenceProvider',
        'GetContact',
        'ListBusinessReportSchedules',
        'ListConferenceProviders',
        'ListDeviceEvents',
        'ListSkillsStoreCategories',
        'ListSkillsStoreSkillsByCategory',
        'ListSmartHomeAppliances',
        'PutConferencePreference',
        'PutSkillAuthorization',
        'RegisterAVSDevice',
        'RejectSkill',
        'SearchAddressBooks',
        'SearchContacts',
        'StartSmartHomeApplianceDiscovery',
        'UpdateAddressBook',
        'UpdateBusinessReportSchedule',
        'UpdateConferenceProvider',
        'UpdateContact',
    ],
    'acm': [
        'ExportCertificate',
        'RenewCertificate',
        'UpdateCertificateOptions',
    ],
    'apigateway': [
        'UpdateRestApiPolicy',
    ],
    'appstream': [
        'BatchAssociateUserStack',
        'BatchDisassociateUserStack',
        'CopyImage',
        'CreateUser',
        'DeleteImagePermissions',
        'DeleteUser',
        'DescribeImagePermissions',
        'DescribeUserStackAssociations',
        'DescribeUsers',
        'DisableUser',
        'EnableUser',
        'UpdateImagePermissions',
    ],
    'appsync': [
        'CreateFunction',
        'DeleteFunction',
        'GetFunction',
        'ListFunctions',
        'UpdateFunction',
    ],
    'athena': [
        'CreateWorkGroup',
        'DeleteWorkGroup',
        'GetQueryResultsStream',
        'GetWorkGroup',
        'ListTagsForResource',
        'ListWorkGroups',
        'TagResource',
        'UntagResource',
        'UpdateWorkGroup',
    ],
    'autoscaling': [
        'BatchDeleteScheduledAction',
        'BatchPutScheduledUpdateGroupAction',
    ],
    'autoscaling_plans': [
        'GetScalingPlanResourceForecastData',
        'UpdateScalingPlan',
    ],
    'aws_marketplace': [
        'RegisterUsage',
    ],
    'aws_marketplace_management': [
        'viewSettings',
    ],
    'awslambda': [
        'AddLayerVersionPermission',
        'DeleteLayerVersion',
        'GetLayerVersion',
        'GetLayerVersionPolicy',
        'ListLayerVersions',
        'ListLayers',
        'PublishLayerVersion',
        'RemoveLayerVersionPermission',
    ],
    'ce': [
        'GetCostForecast',
        'GetReservationCoverage',
        'GetReservationPurchaseRecommendation',
    ],
    'chime': [
        'AssociatePhoneNumbersWithVoiceConnector',
        'AssociatePhoneNumberWithUser',
        'BatchDeletePhoneNumber',
        'BatchSuspendUser',
        'BatchUnsuspendUser',
        'BatchUpdatePhoneNumber',
        'BatchUpdateUser',
        'CreateApiKey',
        'CreateBot',
        'CreateBotMembership',
        'CreatePhoneNumberOrder',
        'CreateVoiceConnector',
        'DeleteAccountOpenIdConfig',
        'DeleteApiKey',
        'DeleteEventsConfiguration',
        'DeletePhoneNumber',
        'DeleteVoiceConnector',
        'DeleteVoiceConnectorOrigination',
        'DeleteVoiceConnectorTermination',
        'DeleteVoiceConnectorTerminationCredentials',
        'DisassociatePhoneNumberFromUser',
        'DisassociatePhoneNumbersFromVoiceConnector',
        'GetAccountWithOpenIdConfig',
        'GetBot',
        'GetEventsConfiguration',
        'GetGlobalSettings',
        'GetMeetingDetail',
        'GetPhoneNumber',
        'GetPhoneNumberOrder',
        'GetTelephonyLimits',
        'GetUserActivityReportData',
        'GetUserSettings',
        'GetVoiceConnector',
        'GetVoiceConnectorOrigination',
        'GetVoiceConnectorTermination',
        'GetVoiceConnectorTerminationHealth',
        'ListAccountUsageReportData',
        'ListApiKeys',
        'ListBots',
        'ListCallingRegions',
        'ListMeetingEvents',
        'ListMeetingsReportData',
        'ListPhoneNumberOrders',
        'ListPhoneNumbers',
        'ListVoiceConnectors',
        'ListVoiceConnectorTerminationCredentials',
        'PutEventsConfiguration',
        'PutVoiceConnectorOrigination',
        'PutVoiceConnectorTermination',
        'PutVoiceConnectorTerminationCredentials',
        'RegenerateSecurityToken',
        'ResetPersonalPIN',
        'RestorePhoneNumber',
        'RetrieveDataExports',
        'SearchAvailablePhoneNumbers',
        'StartDataExport',
        'UpdateAccount',
        'UpdateAccountOpenIdConfig',
        'UpdateBot',
        'UpdateCDRSettings',
        'UpdateGlobalSettings',
        'UpdatePhoneNumber',
        'UpdateUser',
        'UpdateUserSettings',
        'UpdateVoiceConnector',
    ],
    'clouddirectory': [
        'GetLinkAttributes',
        'GetObjectAttributes',
        'UpdateLinkAttributes',
    ],
    'cloudformation': [
        'CreateStackInstances',
        'CreateStackSet',
        'DeleteChangeSet',
        'DeleteStackInstances',
        'DeleteStackSet',
        'DescribeStackDriftDetectionStatus',
        'DescribeStackInstance',
        'DescribeStackResourceDrifts',
        'DescribeStackSet',
        'DescribeStackSetOperation',
        'DetectStackDrift',
        'DetectStackResourceDrift',
        'ListStackInstances',
        'ListStackSetOperationResults',
        'ListStackSetOperations',
        'ListStackSets',
        'StopStackSetOperation',
        'UpdateStackInstances',
        'UpdateStackSet',
    ],
    'cloudhsm': [
        'CreateCluster',
        'DeleteCluster',
        'DescribeBackups',
        'DescribeClusters',
        'InitializeCluster',
        'ListTags',
        'TagResource',
        'UntagResource',
    ],
    'cloudwatch': [
        'DeleteDashboards',
        'GetDashboard',
        'GetMetricWidgetImage',
        'ListDashboards',
        'ListTagsForResource',
        'PutDashboard',
        'TagResource',
        'UntagResource',
    ],
    'codebuild': [
        'CreateWebhook',
        'DeleteOAuthToken',
        'DeleteSourceCredentials',
        'DeleteWebhook',
        'ImportSourceCredentials',
        'InvalidateProjectCache',
        'ListSourceCredentials',
        'UpdateWebhook',
    ],
    'codecommit': [
        'CancelUploadArchive',
        'CreateCommit',
        'DeleteFile',
        'GetFile',
        'GetFolder',
        'GetUploadArchiveStatus',
        'UploadArchive',
    ],
    'codedeploy': [
        'PutLifecycleEventHookExecutionStatus',
    ],
    'codepipeline': [
        'DeleteWebhook',
        'DeregisterWebhookWithThirdParty',
        'ListActionExecutions',
        'ListWebhooks',
        'PutWebhook',
        'RegisterWebhookWithThirdParty',
    ],
    'cognito_identity': [
        'ListTagsForResource',
        'TagResource',
        'UntagResource',
    ],
    'cognito_idp': [
        'AdminDisableProviderForUser',
        'AdminLinkProviderForUser',
        'AdminSetUserPassword',
        'AssociateSoftwareToken',
        'CreateIdentityProvider',
        'CreateResourceServer',
        'CreateUserPoolDomain',
        'DeleteIdentityProvider',
        'DeleteResourceServer',
        'DeleteUserPoolDomain',
        'DescribeIdentityProvider',
        'DescribeResourceServer',
        'DescribeUserPoolDomain',
        'GetIdentityProviderByIdentifier',
        'GetSigningCertificate',
        'GetUICustomization',
        'ListIdentityProviders',
        'ListResourceServers',
        'ListTagsForResource',
        'ListUserPools',
        'ListUsers',
        'SetUICustomization',
        'TagResource',
        'UntagResource',
        'UpdateIdentityProvider',
        'UpdateResourceServer',
        'UpdateUserPoolDomain',
        'VerifySoftwareToken',
    ],
    'comprehend': [
        'BatchDetectSyntax',
        'CreateDocumentClassifier',
        'CreateEntityRecognizer',
        'DeleteDocumentClassifier',
        'DeleteEntityRecognizer',
        'DescribeDocumentClassificationJob',
        'DescribeDocumentClassifier',
        'DescribeDominantLanguageDetectionJob',
        'DescribeEntitiesDetectionJob',
        'DescribeEntityRecognizer',
        'DescribeKeyPhrasesDetectionJob',
        'DescribeSentimentDetectionJob',
        'DetectSyntax',
        'ListDocumentClassificationJobs',
        'ListDocumentClassifiers',
        'ListDominantLanguageDetectionJobs',
        'ListEntitiesDetectionJobs',
        'ListEntityRecognizers',
        'ListKeyPhrasesDetectionJobs',
        'ListSentimentDetectionJobs',
        'ListTagsForResource',
        'StartDocumentClassificationJob',
        'StartDominantLanguageDetectionJob',
        'StartEntitiesDetectionJob',
        'StartKeyPhrasesDetectionJob',
        'StartSentimentDetectionJob',
        'StopDominantLanguageDetectionJob',
        'StopEntitiesDetectionJob',
        'StopKeyPhrasesDetectionJob',
        'StopSentimentDetectionJob',
        'StopTrainingDocumentClassifier',
        'StopTrainingEntityRecognizer',
        'TagResource',
        'UntagResource',
    ],
    'config': [
        'BatchGetAggregateResourceConfig',
        'BatchGetResourceConfig',
        'DeleteAggregationAuthorization',
        'DeleteConfigurationAggregator',
        'DeletePendingAggregationRequest',
        'DeleteRemediationConfiguration',
        'DeleteRetentionConfiguration',
        'DescribeAggregateComplianceByConfigRules',
        'DescribeAggregationAuthorizations',
        'DescribeConfigurationAggregatorSourcesStatus',
        'DescribeConfigurationAggregators',
        'DescribePendingAggregationRequests',
        'DescribeRemediationConfigurations',
        'DescribeRemediationExecutionStatus',
        'DescribeRetentionConfigurations',
        'GetAggregateComplianceDetailsByConfigRule',
        'GetAggregateConfigRuleComplianceSummary',
        'GetAggregateDiscoveredResourceCounts',
        'GetAggregateResourceConfig',
        'GetDiscoveredResourceCounts',
        'ListAggregateDiscoveredResources',
        'ListTagsForResource',
        'PutAggregationAuthorization',
        'PutConfigurationAggregator',
        'PutRemediationConfigurations',
        'PutRetentionConfiguration',
        'SelectResourceConfig',
        'StartRemediationExecution',
        'TagResource',
        'UntagResource',
    ],
    'connect': [
        'GetCurrentMetricData',
        'GetMetricData',
        'StartOutboundVoiceContact',
        'StopContact',
    ],
    'crowd': [
        'ApproveAssignment',
        'ApproveRejectedAssignment',
        'AssignQualification',
        'BlockWorker',
        'ChangeHITTypeOfHIT',
        'CreateHIT',
        'CreateQualificationType',
        'DisableHIT',
        'DisposeHIT',
        'DisposeQualificationType',
        'ExtendHIT',
        'ForceExpireHIT',
        'GetAccountBalance',
        'GetAssignment',
        'GetAssignmentsForHIT',
        'GetBlockedWorkers',
        'GetBonusPayments',
        'GetFileUploadURL',
        'GetHIT',
        'GetHITsForQualificationType',
        'GetQualificationRequests',
        'GetQualificationScore',
        'GetQualificationType',
        'GetQualificationsForQualificationType',
        'GetRequesterStatistic',
        'GetRequesterWorkerStatistic',
        'GetReviewResultsForHIT',
        'GetReviewableHITs',
        'GrantBonus',
        'GrantQualification',
        'NotifyWorkers',
        'RegisterHITType',
        'RejectAssignment',
        'RejectQualificationRequest',
        'RevokeQualification',
        'SearchHITs',
        'SearchQualificationTypes',
        'SendTestEventNotification',
        'SetHITAsReviewing',
        'SetHITTypeNotification',
        'UnblockWorker',
        'UpdateQualificationScore',
        'UpdateQualificationType',
    ],
    'dax': [
        'ConditionCheckItem',
    ],
    'directconnect': [
        'AllocateHostedConnection',
        'AssociateConnectionWithLag',
        'AssociateHostedConnection',
        'AssociateVirtualInterface',
        'CreateBGPPeer',
        'CreateDirectConnectGateway',
        'CreateDirectConnectGatewayAssociation',
        'CreateLag',
        'DeleteBGPPeer',
        'DeleteDirectConnectGateway',
        'DeleteDirectConnectGatewayAssociation',
        'DeleteLag',
        'DescribeDirectConnectGatewayAssociations',
        'DescribeDirectConnectGatewayAttachments',
        'DescribeDirectConnectGateways',
        'DescribeHostedConnections',
        'DescribeLags',
        'DescribeLoa',
        'DescribeTags',
        'DisassociateConnectionFromLag',
        'TagResource',
        'UntagResource',
        'UpdateLag',
        'UpdateVirtualInterfaceAttributes',
    ],
    'discovery': [
        'BatchDeleteImportData',
        'DescribeContinuousExports',
        'DescribeExportTasks',
        'DescribeImportTasks',
        'StartContinuousExport',
        'StartImportTask',
        'StopContinuousExport',
    ],
    'ds': [
        'AcceptSharedDirectory',
        'CreateIdentityPoolDirectory',
        'CreateLogSubscription',
        'DeleteLogSubscription',
        'DescribeDomainControllers',
        'DescribeSharedDirectories',
        'GetAuthorizedApplicationDetails',
        'ListLogSubscriptions',
        'RejectSharedDirectory',
        'ResetUserPassword',
        'ShareDirectory',
        'UnshareDirectory',
        'UpdateNumberOfDomainControllers',
    ],
    'dynamodb': [
        'ConditionCheckItem',
        'CreateGlobalTable',
        'DescribeGlobalTable',
        'DescribeGlobalTableSettings',
        'DescribeTimeToLive',
        'ListGlobalTables',
        'UpdateGlobalTable',
        'UpdateGlobalTableSettings',
        'UpdateTimeToLive',
    ],
    'ec2': [
        'AcceptTransitGatewayVpcAttachment',
        'AdvertiseByoipCidr',
        'ApplySecurityGroupsToClientVpnTargetNetwork',
        'AssociateClientVpnTargetNetwork',
        'AssociateTransitGatewayRouteTable',
        'AuthorizeClientVpnIngress',
        'CancelCapacityReservation',
        'CreateCapacityReservation',
        'CreateClientVpnEndpoint',
        'CreateClientVpnRoute',
        'CreateFleet',
        'CreateTransitGateway',
        'CreateTransitGatewayRoute',
        'CreateTransitGatewayRouteTable',
        'CreateTransitGatewayVpcAttachment',
        'DeleteClientVpnEndpoint',
        'DeleteClientVpnRoute',
        'DeleteFleets',
        'DeleteTransitGateway',
        'DeleteTransitGatewayRoute',
        'DeleteTransitGatewayRouteTable',
        'DeleteTransitGatewayVpcAttachment',
        'DeprovisionByoipCidr',
        'DescribeAggregateIdFormat',
        'DescribeByoipCidrs',
        'DescribeCapacityReservations',
        'DescribeClientVpnAuthorizationRules',
        'DescribeClientVpnConnections',
        'DescribeClientVpnEndpoints',
        'DescribeClientVpnRoutes',
        'DescribeClientVpnTargetNetworks',
        'DescribeFleetHistory',
        'DescribeFleetInstances',
        'DescribeFleets',
        'DescribePrincipalIdFormat',
        'DescribePublicIpv4Pools',
        'DescribeTransitGatewayAttachments',
        'DescribeTransitGatewayRouteTables',
        'DescribeTransitGatewayVpcAttachments',
        'DescribeTransitGateways',
        'DisableTransitGatewayRouteTablePropagation',
        'DisassociateClientVpnTargetNetwork',
        'DisassociateTransitGatewayRouteTable',
        'EnableTransitGatewayRouteTablePropagation',
        'ExportClientVpnClientCertificateRevocationList',
        'ExportClientVpnClientConfiguration',
        'ExportTransitGatewayRoutes',
        'GetTransitGatewayAttachmentPropagations',
        'GetTransitGatewayRouteTableAssociations',
        'GetTransitGatewayRouteTablePropagations',
        'ImportClientVpnClientCertificateRevocationList',
        'ModifyCapacityReservation',
        'ModifyClientVpnEndpoint',
        'ModifyFleet',
        'ModifyInstanceCapacityReservationAttributes',
        'ModifyInstanceEventStartTime',
        'ModifyTransitGatewayVpcAttachment',
        'ProvisionByoipCidr',
        'RejectTransitGatewayVpcAttachment',
        'ReplaceTransitGatewayRoute',
        'RevokeClientVpnIngress',
        'SearchTransitGatewayRoutes',
        'TerminateClientVpnConnections',
        'WithdrawByoipCidr',
    ],
    'ecr': [
        'DeleteLifecyclePolicy',
        'GetLifecyclePolicy',
        'GetLifecyclePolicyPreview',
        'ListTagsForResource',
        'PutLifecyclePolicy',
        'StartLifecyclePolicyPreview',
        'TagResource',
        'UntagResource',
    ],
    'ecs': [
        'CreateTaskSet',
        'DeleteAccountSetting',
        'DeleteAccountSettings',
        'DeleteAttributes',
        'DeleteTaskSet',
        'DescribeTaskSets',
        'ListAccountSettings',
        'ListAttributes',
        'ListTagsForResource',
        'PutAccountSetting',
        'PutAccountSettingDefault',
        'PutAttributes',
        'TagResource',
        'UntagResource',
        'UpdateServicePrimaryTaskSet',
        'UpdateTaskSet',
    ],
    'elasticache': [
        'DecreaseReplicaCount',
        'IncreaseReplicaCount',
        'ModifyReplicationGroupShardConfiguration',
        'TestFailover',
    ],
    'elasticbeanstalk': [
        'DescribeAccountAttributes',
    ],
    'elasticfilesystem': [
        'DescribeLifecycleConfiguration',
        'PutLifecycleConfiguration',
        'UpdateFileSystem',
    ],
    'elasticmapreduce': [
        'AddInstanceFleet',
        'CreateEditor',
        'DeleteEditor',
        'DescribeEditor',
        'ListEditors',
        'ListInstanceFleets',
        'ModifyInstanceFleet',
        'OpenEditorInConsole',
        'StartEditor',
        'StopEditor',
    ],
    'es': [
        'DeleteElasticsearchServiceRole',
        'DescribeElasticsearchInstanceTypeLimits',
        'DescribeReservedElasticsearchInstanceOfferings',
        'DescribeReservedElasticsearchInstances',
        'ESHttpDelete',
        'ESHttpGet',
        'ESHttpHead',
        'ESHttpPost',
        'ESHttpPut',
        'GetCompatibleElasticsearchVersions',
        'GetUpgradeHistory',
        'GetUpgradeStatus',
        'ListElasticsearchInstanceTypes',
        'ListElasticsearchVersions',
        'PurchaseReservedElasticsearchInstance',
        'UpgradeElasticsearchDomain',

    ],
    'events': [
        'DescribeEventBus',
        'ListTagsForResource',
        'PutPermission',
        'RemovePermission',
        'TagResource',
        'UntagResource',
    ],
    'firehose': [
        'ListTagsForDeliveryStream', 'StartDeliveryStreamEncryption',
        'StopDeliveryStreamEncryption', 'TagDeliveryStream',
        'UntagDeliveryStream',
    ],
    'glue': [
        'BatchDeleteTableVersion', 'BatchGetCrawlers', 'BatchGetDevEndpoints',
        'BatchGetJobs', 'BatchGetTriggers', 'BatchStopJobRun',
        'DeleteResourcePolicy', 'DeleteTableVersion', 'GetResourcePolicy',
        'GetTableVersion', 'GetTags', 'ListCrawlers', 'ListDevEndpoints',
        'ListJobs', 'ListTriggers', 'PutResourcePolicy', 'TagResource',
        'UntagResource', 'UpdateCrawlerSchedule',
    ],
    'greengrass': [
        'CreateConnectorDefinition',
        'CreateConnectorDefinitionVersion',
        'DeleteConnectorDefinition',
        'GetBulkDeploymentStatus',
        'GetConnectorDefinition',
        'GetConnectorDefinitionVersion',
        'ListBulkDeploymentDetailedReports',
        'ListBulkDeployments',
        'ListConnectorDefinitionVersions',
        'ListConnectorDefinitions',
        'ListTagsForResource',
        'StartBulkDeployment',
        'StopBulkDeployment',
        'TagResource',
        'UntagResource',
        'UpdateConnectorDefinition',
    ],
    'iam': [
        'DeleteRolePermissionsBoundary',
        'DeleteUserPermissionsBoundary',
        'FinalizeSmsMfaRegistration',
        'ListRoleTags',
        'ListUserTags',
        'PutRolePermissionsBoundary',
        'PutUserPermissionsBoundary',
        'RequestSmsMfaRegistration',
        'SetSecurityTokenServicePreferences',
        'TagRole',
        'TagUser',
        'UntagRole',
        'UntagUser',
        'UpdateRole',
    ],
    'iot': [
        'AddThingToBillingGroup',
        'AddThingToThingGroup',
        'CancelJobExecution',
        'CreateBillingGroup',
        'CreateOTAUpdate',
        'CreateThingGroup',
        'DeleteBillingGroup',
        'DeleteJob',
        'DeleteJobExecution',
        'DeleteOTAUpdate',
        'DeleteThingGroup',
        'DeleteV2LoggingLevel',
        'DescribeBillingGroup',
        'DescribeEventConfigurations',
        'DescribeThingGroup',
        'DescribeThingRegistrationTask',
        'GetOTAUpdate',
        'GetPendingJobExecutions',
        'GetV2LoggingOptions',
        'ListBillingGroups',
        'ListOTAUpdates',
        'ListTagsForResource',
        'ListThingGroups',
        'ListThingGroupsForThing',
        'ListThingRegistrationTaskReports',
        'ListThingRegistrationTasks',
        'ListThingsInBillingGroup',
        'ListThingsInThingGroup',
        'ListV2LoggingLevels',
        'RegisterThing',
        'RemoveThingFromBillingGroup',
        'RemoveThingFromThingGroup',
        'SetV2LoggingLevel',
        'SetV2LoggingOptions',
        'StartNextPendingJobExecution',
        'StartThingRegistrationTask',
        'StopThingRegistrationTask',
        'TagResource',
        'UntagResource',
        'UpdateBillingGroup',
        'UpdateEventConfigurations',
        'UpdateJob',
        'UpdateJobExecution',
        'UpdateThingGroup',
        'UpdateThingGroupsForThing',
    ],
    'iotanalytics': [
        'BatchPutMessage',
        'CancelPipelineReprocessing',
        'DescribeLoggingOptions',
        'ListTagsForResource',
        'PutLoggingOptions',
        'RunPipelineActivity',
        'SampleChannelData',
        'StartPipelineReprocessing',
        'TagResource',
        'UntagResource',
        'UpdateChannel',
        'UpdateDatastore',
    ],
    'kinesis': [
        'DeregisterStreamConsumer', 'DescribeStreamConsumer',
        'DescribeStreamSummary', 'ListShards', 'ListStreamConsumers',
        'RegisterStreamConsumer', 'SubscribeToShard',
    ],
    'kinesisvideo': [
        'GetHLSStreamingSessionURL',
    ],
    'lightsail': [
        'AttachDisk',
        'AttachInstancesToLoadBalancer',
        'AttachLoadBalancerTlsCertificate',
        'CopySnapshot',
        'CreateCloudFormationStack',
        'CreateDisk',
        'CreateDiskFromSnapshot',
        'CreateDiskSnapshot',
        'CreateLoadBalancer',
        'CreateLoadBalancerTlsCertificate',
        'CreateRelationalDatabase',
        'CreateRelationalDatabaseFromSnapshot',
        'CreateRelationalDatabaseSnapshot',
        'DeleteDisk',
        'DeleteDiskSnapshot',
        'DeleteKnownHostKeys',
        'DeleteLoadBalancer',
        'DeleteLoadBalancerTlsCertificate',
        'DeleteRelationalDatabase',
        'DeleteRelationalDatabaseSnapshot',
        'DetachDisk',
        'DetachInstancesFromLoadBalancer',
        'ExportSnapshot',
        'GetCloudFormationStackRecords',
        'GetDisk',
        'GetDiskSnapshot',
        'GetDiskSnapshots',
        'GetDisks',
        'GetExportSnapshotRecords',
        'GetLoadBalancer',
        'GetLoadBalancerMetricData',
        'GetLoadBalancerTlsCertificates',
        'GetLoadBalancers',
        'GetRelationalDatabase',
        'GetRelationalDatabaseBlueprints',
        'GetRelationalDatabaseBundles',
        'GetRelationalDatabaseEvents',
        'GetRelationalDatabaseLogEvents',
        'GetRelationalDatabaseLogStreams',
        'GetRelationalDatabaseMasterUserPassword',
        'GetRelationalDatabaseMetricData',
        'GetRelationalDatabaseParameters',
        'GetRelationalDatabaseSnapshot',
        'GetRelationalDatabaseSnapshots',
        'GetRelationalDatabases',
        'PutInstancePublicPorts',
        'RebootRelationalDatabase',
        'StartRelationalDatabase',
        'StopRelationalDatabase',
        'TagResource',
        'UntagResource',
        'UpdateLoadBalancerAttribute',
        'UpdateRelationalDatabase',
        'UpdateRelationalDatabaseParameters',
    ],
    'logs': [
        'CreateLogDelivery',
        'DeleteLogDelivery',
        'DescribeQueries',
        'GetLogDelivery',
        'GetLogGroupFields',
        'GetLogRecord',
        'GetQueryResults',
        'ListLogDeliveries',
        'StartQuery',
        'StopQuery',
        'UpdateLogDelivery',
    ],
    'mediaconvert': [
        'AssociateCertificate',
        'DescribeEndpoints',
        'DisassociateCertificate',
        'ListTagsForResource',
        'TagResource',
        'UntagResource',
    ],
    'medialive': [
        'BatchUpdateSchedule',
        'CreateTags',
        'DeleteReservation',
        'DeleteTags',
        'DescribeOffering',
        'DescribeReservation',
        'DescribeSchedule',
        'ListOfferings',
        'ListReservations',
        'ListTagsForResource',
        'PurchaseOffering',
        'UpdateChannel',
        'UpdateInput',
        'UpdateInputSecurityGroup',
        'UpdateReservation',
    ],
    'mediapackage': [
        'ListTagsForResource',
        'RotateIngestEndpointCredentials',
        'TagResource',
        'UntagResource',
    ],
    'mediastore': [
        'DeleteCorsPolicy',
        'DeleteLifecyclePolicy',
        'GetCorsPolicy',
        'GetLifecyclePolicy',
        'PutCorsPolicy',
        'PutLifecyclePolicy',
        'StartAccessLogging',
        'StopAccessLogging',
    ],
    'mobilehub': [
        'DeleteProjectSnapshot',
        'InstallBundle',
        'ListProjectSnapshots',
    ],
    'mobiletargeting': [
        'CreateApp',
        'CreateExportJob',
        'DeleteApnsVoipChannel',
        'DeleteApnsVoipSandboxChannel',
        'DeleteApp',
        'DeleteBaiduChannel',
        'DeleteEmailChannel',
        'DeleteEndpoint',
        'DeleteEventStream',
        'DeleteSmsChannel',
        'DeleteUserEndpoints',
        'DeleteVoiceChannel',
        'GetApnsVoipChannel',
        'GetApnsVoipSandboxChannel',
        'GetApp',
        'GetApps',
        'GetBaiduChannel',
        'GetChannels',
        'GetEmailChannel',
        'GetEventStream',
        'GetExportJob',
        'GetExportJobs',
        'GetSegmentExportJobs',
        'GetSmsChannel',
        'GetUserEndpoints',
        'GetVoiceChannel',
        'ListTagsForResource',
        'PhoneNumberValidate',
        'PutEventStream',
        'PutEvents',
        'RemoveAttributes',
        'SendMessages',
        'SendUsersMessages',
        'TagResource',
        'UntagResource',
        'UpdateApnsVoipChannel',
        'UpdateApnsVoipSandboxChannel',
        'UpdateBaiduChannel',
        'UpdateEmailChannel',
        'UpdateSmsChannel',
        'UpdateVoiceChannel',
    ],
    'mq': [
        'CreateTags',
        'DeleteTags',
        'DescribeBrokerEngineTypes',
        'DescribeBrokerInstanceOptions',
        'ListTags',
    ],
    'organizations': [
        'CreateGovCloudAccount',
        'DisableAWSServiceAccess',
        'EnableAWSServiceAccess',
        'ListAWSServiceAccessForOrganization',
    ],
    'polly': [
        'GetSpeechSynthesisTask',
        'ListSpeechSynthesisTasks',
        'StartSpeechSynthesisTask',
    ],
    'rds': [
        'AddRoleToDBInstance',
        'BacktrackDBCluster',
        'CopyDBClusterParameterGroup',
        'CreateDBClusterEndpoint',
        'CreateGlobalCluster',
        'DeleteDBClusterEndpoint',
        'DeleteDBInstanceAutomatedBackup',
        'DeleteGlobalCluster',
        'DescribeDBClusterBacktracks',
        'DescribeDBClusterEndpoints',
        'DescribeDBInstanceAutomatedBackups',
        'DescribeGlobalClusters',
        'DescribeSourceRegions',
        'DescribeValidDBInstanceModifications',
        'ModifyCurrentDBClusterCapacity',
        'ModifyDBClusterEndpoint',
        'ModifyDBSnapshot',
        'ModifyGlobalCluster',
        'PromoteReadReplicaDBCluster',
        'RemoveFromGlobalCluster',
        'RemoveRoleFromDBCluster',
        'RemoveRoleFromDBInstance',
        'RestoreDBClusterFromS3',
        'RestoreDBInstanceFromS3',
        'StartDBCluster',
        'StopDBCluster',
    ],
    'redshift': [
        'AcceptReservedNodeExchange',
        'BatchDeleteClusterSnapshots',
        'BatchModifyClusterSnapshots',
        'CancelQuery',
        'CancelResize',
        'CreateSavedQuery',
        'CreateSnapshotSchedule',
        'DeleteSavedQueries',
        'DeleteSnapshotSchedule',
        'DescribeAccountAttributes',
        'DescribeClusterDbRevisions',
        'DescribeClusterTracks',
        'DescribeQuery',
        'DescribeSnapshotSchedules',
        'DescribeStorage',
        'DescribeTable',
        'ExecuteQuery',
        'FetchResults',
        'GetReservedNodeExchangeOfferings',
        'ListDatabases',
        'ListSavedQueries',
        'ListSchemas',
        'ListTables',
        'ModifyClusterDbRevision',
        'ModifyClusterMaintenance',
        'ModifyClusterSnapshot',
        'ModifyClusterSnapshotSchedule',
        'ModifySavedQuery',
        'ModifySnapshotSchedule',
        'ResizeCluster',
        'ViewQueriesFromConsole',
    ],
    'rekognition': [
        'DescribeCollection',
    ],
    'route53': [
        'CreateQueryLoggingConfig',
        'DeleteQueryLoggingConfig',
        'GetAccountLimit',
        'GetHostedZoneLimit',
        'GetQueryLoggingConfig',
        'GetReusableDelegationSetLimit',
        'ListQueryLoggingConfigs',
    ],
    's3': [
        'GetAccountPublicAccessBlock',
        'GetBucketPolicyStatus',
        'GetBucketPublicAccessBlock',
        'GetEncryptionConfiguration',
        'ObjectOwnerOverrideToBucketOwner',
        'PutAccountPublicAccessBlock',
        'PutBucketPublicAccessBlock',
        'PutEncryptionConfiguration',
        'ReplicateTags',
    ],
    'sagemaker': [
        'CreateAlgorithm',
        'CreateCodeRepository',
        'CreateCompilationJob',
        'CreateHyperParameterTuningJob',
        'CreateLabelingJob',
        'CreateModelPackage',
        'CreateNotebookInstanceLifecycleConfig',
        'CreateTransformJob',
        'CreateWorkteam',
        'DeleteAlgorithm',
        'DeleteCodeRepository',
        'DeleteModelPackage',
        'DeleteNotebookInstanceLifecycleConfig',
        'DeleteWorkteam',
        'DescribeAlgorithm',
        'DescribeCodeRepository',
        'DescribeCompilationJob',
        'DescribeHyperParameterTuningJob',
        'DescribeLabelingJob',
        'DescribeModelPackage',
        'DescribeNotebookInstanceLifecycleConfig',
        'DescribeSubscribedWorkteam',
        'DescribeTransformJob',
        'DescribeWorkteam',
        'GetSearchSuggestions',
        'ListAlgorithms',
        'ListCodeRepositories',
        'ListCompilationJobs',
        'ListHyperParameterTuningJobs',
        'ListLabelingJobs',
        'ListLabelingJobsForWorkteam',
        'ListModelPackages',
        'ListNotebookInstanceLifecycleConfigs',
        'ListSubscribedWorkteams',
        'ListTrainingJobsForHyperParameterTuningJob',
        'ListTransformJobs',
        'ListWorkteams',
        'RenderUiTemplate',
        'Search',
        'StopCompilationJob',
        'StopHyperParameterTuningJob',
        'StopLabelingJob',
        'StopTransformJob',
        'UpdateCodeRepository',
        'UpdateNotebookInstanceLifecycleConfig',
        'UpdateWorkteam',
    ],
    'serverlessrepo': [
        'CreateCloudFormationTemplate',
        'GetCloudFormationTemplate',
        'ListApplicationDependencies',
    ],
    'servicecatalog': [
        'AssociateServiceActionWithProvisioningArtifact',
        'AssociateTagOptionWithResource',
        'BatchAssociateServiceActionWithProvisioningArtifact',
        'BatchDisassociateServiceActionFromProvisioningArtifact',
        'CopyProduct',
        'CreateProvisionedProductPlan',
        'CreateServiceAction',
        'CreateTagOption',
        'DeleteProvisionedProductPlan',
        'DeleteServiceAction',
        'DeleteTagOption',
        'DescribeCopyProductStatus',
        'DescribePortfolioShareStatus',
        'DescribeProvisionedProduct',
        'DescribeProvisionedProductPlan',
        'DescribeServiceAction',
        'DescribeTagOption',
        'DisableAWSOrganizationsAccess',
        'DisassociateServiceActionFromProvisioningArtifact',
        'DisassociateTagOptionFromResource',
        'EnableAWSOrganizationsAccess',
        'ExecuteProvisionedProductPlan',
        'ExecuteProvisionedProductServiceAction',
        'GetAWSOrganizationsAccessStatus',
        'ListOrganizationPortfolioAccess',
        'ListProvisionedProductPlans',
        'ListProvisioningArtifactsForServiceAction',
        'ListResourcesForTagOption',
        'ListServiceActions',
        'ListServiceActionsForProvisioningArtifact',
        'ListTagOptions',
        'SearchProvisionedProducts',
        'UpdateServiceAction',
        'UpdateTagOption',
    ],
    'servicediscovery': [
        'CreateHttpNamespace',
        'DiscoverInstances',
        'UpdateInstanceCustomHealthStatus',
    ],
    'shield': [
        'AssociateDRTLogBucket',
        'AssociateDRTRole',
        'DescribeDRTAccess',
        'DescribeEmergencyContactSettings',
        'DisassociateDRTLogBucket',
        'DisassociateDRTRole',
        'GetSubscriptionState',
        'UpdateEmergencyContactSettings',
    ],
    'signer': [
        'CancelSigningProfile',
        'GetSigningPlatform',
        'GetSigningProfile',
        'ListSigningPlatforms',
        'ListSigningProfiles',
        'PutSigningProfile',
    ],
    'ssm': [
        'DescribeAssociationExecutions',
        'DescribeAssociationExecutionTargets',
        'DescribeSessions',
        'GetConnectionStatus',
        'ListComplianceItems',
        'ListComplianceSummaries',
        'ListResourceComplianceSummaries',
        'ResumeSession',
        'StartSession',
        'TerminateSession',
        'UpdateInstanceInformation',
    ],
    'sso': [
        'AddMemberToGroup',
        'CreateAlias',
        'CreateGroup',
        'CreateUser',
        'DeleteGroup',
        'DeleteUser',
        'DescribeGroups',
        'DescribeUsers',
        'DisableUser',
        'EnableUser',
        'GetPermissionsPolicy',
        'GetSSOConfiguration',
        'GetUserPoolInfo',
        'ListApplications',
        'ListGroupsForUser',
        'ListMembersInGroup',
        'RemoveMemberFromGroup',
        'SearchGroups',
        'SearchUsers',
        'SetTemporaryPassword',
        'UpdateGroup',
        'UpdatePermissionSet',
        'UpdateSSOConfiguration',
        'UpdateUser',
    ],
    'states': [
        'ListTagsForResource',
        'TagResource',
        'UntagResource',
    ],
    'storagegateway': [
        'AttachVolume',
        'CreateSMBFileShare',
        'DescribeSMBFileShares',
        'DescribeSMBSettings',
        'DetachVolume',
        'JoinDomain',
        'NotifyWhenUploaded',
        'SetSMBGuestPassword',
        'UpdateSMBFileShare',
    ],
    'transcribe': [
        'CreateVocabulary',
        'DeleteTranscriptionJob',
        'DeleteVocabulary',
        'GetVocabulary',
        'ListVocabularies',
        'StartStreamTranscription',
        'UpdateVocabulary',
    ],
    'translate': [
        'DeleteTerminology',
        'GetTerminology',
        'ImportTerminology',
        'ListTerminologies',
    ],
    'waf': [
        'CreateRuleGroup',
        'DeleteLoggingConfiguration',
        'DeletePermissionPolicy',
        'DeleteRuleGroup',
        'GetLoggingConfiguration',
        'GetPermissionPolicy',
        'GetRuleGroup',
        'ListActivatedRulesInRuleGroup',
        'ListLoggingConfigurations',
        'ListRuleGroups',
        'ListSubscribedRuleGroups',
        'PutLoggingConfiguration',
        'PutPermissionPolicy',
        'UpdateRuleGroup',
    ],
    'waf_regional': [
        'CreateRuleGroup',
        'DeleteLoggingConfiguration',
        'DeletePermissionPolicy',
        'DeleteRuleGroup',
        'GetLoggingConfiguration',
        'GetPermissionPolicy',
        'GetRuleGroup',
        'ListActivatedRulesInRuleGroup',
        'ListLoggingConfigurations',
        'ListRuleGroups',
        'ListSubscribedRuleGroups',
        'PutLoggingConfiguration',
        'PutPermissionPolicy',
        'UpdateRuleGroup',
    ],
    'workspaces': [
        'AssociateIpGroups',
        'AuthorizeIpRules',
        'CreateIpGroup',
        'DeleteIpGroup',
        'DeleteWorkspaceImage',
        'DescribeAccount',
        'DescribeAccountModifications',
        'DescribeClientProperties',
        'DescribeIpGroups',
        'DescribeWorkspaceImages',
        'DisassociateIpGroups',
        'ImportWorkspaceImage',
        'ListAvailableManagementCidrRanges',
        'ModifyAccount',
        'ModifyClientProperties',
        'ModifyWorkspaceState',
        'RevokeIpRules',
        'UpdateRulesOfIpGroup',
    ],
    'xray': [
        'CreateGroup',
        'CreateSamplingRule',
        'DeleteGroup',
        'DeleteSamplingRule',
        'GetEncryptionConfig',
        'GetGroup',
        'GetGroups',
        'GetSamplingRules',
        'GetSamplingStatisticSummaries',
        'GetSamplingTargets',
        'GetTimeSeriesServiceStatistics',
        'PutEncryptionConfig',
        'UpdateGroup',
        'UpdateSamplingRule',
    ]
}


# Some actions appear to be deleted but still in the docs. This grouping
# will keep them available as it gets sorted out.

deleted_actions = {
    'cloudsearch': [
        'DefineIndexFields',
    ],
    'cognito-idp': [
        'ListUserPools', 'ListUsers',
    ],
    'dax': [
        'DefineAttributeList', 'DefineAttributeListId', 'DefineKeySchema',
    ],
    'ec2': [
        'ModifySpotFleetRequest',
    ],
    'elasticbeanstalk': [
        'AddTags', 'ListTagsForResource', 'RemoveTags',
    ],
    'glue': [
        'GetDataCatalogEncryptionSettings', 'PutDataCatalogEncryptionSettings',
        'CreateSecurityConfiguration', 'GetSecurityConfiguration',
        'GetSecurityConfigurations', 'DeleteSecurityConfiguration',
    ],
    'kinesis': [
        'StartStreamEncryption', 'StopStreamEncryption',
    ],
    'kinesisanalytics': [
        'GetApplicationState',
    ],
    'kms': [
        'ConnectCustomKeyStore',
        'CreateCustomKeyStore',
        'DeleteCustomKeyStore',
        'DescribeCustomKeyStores',
        'DisconnectCustomKeyStore',
        'ReEncrypt',
        'UpdateCustomKeyStore',
    ],
    'mechanicalturk': [
        'AcceptQualificationRequest', 'AssociateQualificationWithWorker',
        'CreateHITType', 'CreateHITWithHITType', 'CreateWorkerBlock',
        'DeleteHIT', 'DeleteQualificationType', 'DeleteWorkerBlock',
        'DisassociateQualificationFromWorker', 'ListAssignmentsForHIT',
        'ListBonusPayments', 'ListHITs', 'ListHITsForQualificationType',
        'ListQualificationRequests', 'ListQualificationTypes',
        'ListReviewPolicyResultsForHIT', 'ListReviewableHITs',
        'ListWorkerBlocks', 'ListWorkersWithQualificationType',
        'SendBonus', 'UpdateExpirationForHIT', 'UpdateHITReviewStatus',
        'UpdateHITTypeOfHIT', 'UpdateNotificationSettings',

    ],
    'mobilehub': [
        'ValidateProject',
    ],
    'mobiletargeting': [
        'DeleteAdmChannel', 'DeleteAdmChannel', 'DeleteApnsSandboxChannel',
        'GetAdmChannel', 'GetApnsSandboxChannel', 'UpdateAdmChannel',
        'UpdateApnsSandboxChannel',
    ],
    'route53': [
        'CreateVPCAssociationAuthorization',
        'DeleteVPCAssociationAuthorization',
        'ListVPCAssociationAuthorizations',
    ],
    'route53domain': [
        'DeleteDomain',
    ],
    'tag': [
        'AddResourceTags', 'RemoveResourceTags',
    ],
}

# patch in the extra_services if they are not present in policies.js
for service_name in extra_services:
    if not d['serviceMap'].get(service_name):
        d['serviceMap'][service_name] = extra_services[service_name]


filename_seen = {}
for serviceName, serviceValue in d['serviceMap'].items():
    prefix = serviceValue['StringPrefix']
    service = prefix
    # Handle prefix such as "directconnect:"
    if prefix[-1] == ':':
        service = prefix[:-1]
    if service == 'lambda':
        service = 'awslambda'
    service = service.replace("-", "_")
    filename = ''.join([basedir, "/", service, ".py"])
    with open(filename, "a") as fp:
        if filename not in filename_seen:
            filename_seen[filename] = True
            if prefix in legacy_arns:
                fp.write("import warnings\n")
            fp.write(header)
            fp.write("\n")
            fp.write("service_name = '%s'\n" % (serviceName,))
            fp.write("prefix = '%s'\n" % (prefix,))
            fp.write("\n\n")
            if service == "s3":
                fp.write(extra_classes_s3)
            else:
                fp.write(extra_classes)
            fp.write("\n\n")
            if prefix in legacy_arns:
                fp.write(arn % {
                    'lower': prefix,
                    'upper': prefix.upper(),
                })
                fp.write("\n\n")

        # Add actions AWS hasn't added yet
        if service in extra_actions:
            serviceValue['Actions'].extend(extra_actions[service])

        # Add actions AWS may have inadvertantly deleted
        if service in deleted_actions:
            serviceValue['Actions'].extend(deleted_actions[service])

        # Make the set sorted and unique
        serviceValue['Actions'] = sorted(set(serviceValue['Actions']))

        for action in serviceValue['Actions']:
            action = action.strip()
            # Handle action such as "ReEncrypt*"
            if action[-1] == '*':
                action = action[:-1]
            # Wrap lines for pep8
            if len(action) > 30:
                format = "%s = \\\n    Action('%s')\n"
            else:
                format = "%s = Action('%s')\n"
            fp.write(format % (action, action))
