예제 #1
0
파일: _arg.py 프로젝트: woakesd/azure-cli
 def to_cmd_arg(self, name):
     from azure.cli.core.commands.parameters import get_location_completion_list
     from azure.cli.core.local_context import LocalContextAttribute, LocalContextAction, ALL
     arg = super().to_cmd_arg(name)
     arg.completer = get_location_completion_list
     arg.configured_default = 'location'
     arg.local_context_attribute = LocalContextAttribute(
         name='location',
         actions=[LocalContextAction.SET, LocalContextAction.GET],
         scopes=[ALL])
     return arg
예제 #2
0
def load_arguments(self, _):

    for command_group in ('mysql', 'postgres'):
        server_name_arg_type = CLIArgumentType(metavar='NAME',
                                               help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                               local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET, LocalContextAction.GET], scopes=['{} flexible-server'.format(command_group)]))

        administrator_login_arg_type = CLIArgumentType(metavar='NAME',
                                                       local_context_attribute=LocalContextAttribute(name='administrator_login', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        database_name_arg_type = CLIArgumentType(metavar='NAME',
                                                 local_context_attribute=LocalContextAttribute(name='database_name', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        with self.argument_context('{} flexible-server connect'.format(command_group)) as c:
            c.argument('server_name', id_part=None, options_list=['--name', '-n'], arg_type=server_name_arg_type)
            c.argument('administrator_login', arg_group='Authentication', arg_type=administrator_login_arg_type, options_list=['--admin-user', '-u'],
                       help='The login username of the administrator.')
            c.argument('administrator_login_password', arg_group='Authentication', options_list=['--admin-password', '-p'],
                       help='The login password of the administrator.')
            c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
            c.argument('interactive_mode', options_list=['--interactive'], action='store_true', help='Pass this parameter to connect to database in interactive mode.')
            c.argument('querytext', options_list=['--querytext', '-q'], help='A query to run against the flexible server.')
예제 #3
0
def get_location_type(cli_ctx):
    location_type = CLIArgumentType(
        options_list=['--location', '-l'],
        completer=get_location_completion_list,
        type=get_location_name_type(cli_ctx),
        help="Location. Values from: `az account list-locations`. "
        "You can configure the default location using `az configure --defaults location=<location>`.",
        metavar='LOCATION',
        configured_default='location',
        local_context_attribute=LocalContextAttribute(
            name='location',
            actions=[LocalContextAction.SET, LocalContextAction.GET],
            scopes=[ALL]))
    return location_type
예제 #4
0
def load_arguments(self, _):
    # pylint: disable=line-too-long
    # PARAMETER REGISTRATION

    with self.argument_context('functionapp devops-pipeline') as c:
        c.argument('functionapp_name',
                   help="Name of the Azure Function App that you want to use",
                   required=False,
                   local_context_attribute=LocalContextAttribute(
                       name='functionapp_name',
                       actions=[LocalContextAction.GET]))
        c.argument(
            'organization_name',
            help="Name of the Azure DevOps organization that you want to use",
            required=False)
        c.argument(
            'project_name',
            help="Name of the Azure DevOps project that you want to use",
            required=False)
        c.argument(
            'repository_name',
            help="Name of the Azure DevOps repository that you want to use",
            required=False)
        c.argument(
            'overwrite_yaml',
            help="If you have an existing yaml, should it be overwritten?",
            arg_type=get_three_state_flag(return_label=True),
            required=False)
        c.argument(
            'allow_force_push',
            help=
            "If Azure DevOps repository is not clean, should it overwrite remote content?",
            arg_type=get_three_state_flag(return_label=True),
            required=False)
        c.argument(
            'github_pat',
            help=
            "Github personal access token for creating pipeline from Github repository",
            required=False)
        c.argument(
            'github_repository',
            help="Fullname of your Github repository (e.g. Azure/azure-cli)",
            required=False)
예제 #5
0
    def _complex_params(command_group):

        server_name_setter_arg_type = CLIArgumentType(metavar='NAME',
                                                      help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                                      local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET], scopes=['{} server'.format(command_group)]))

        server_name_getter_arg_type = CLIArgumentType(metavar='NAME',
                                                      help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                                      local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.GET], scopes=['{} server'.format(command_group)]))

        server_name_arg_type = CLIArgumentType(metavar='NAME',
                                               help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                               local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET, LocalContextAction.GET], scopes=['{} server'.format(command_group)]))

        overriding_none_arg_type = CLIArgumentType(local_context_attribute=LocalContextAttribute(name='context_name', actions=[LocalContextAction.GET]))

        with self.argument_context(command_group) as c:
            c.argument('name', options_list=['--sku-name'], required=True)
            c.argument('server_name', arg_type=server_name_arg_type, completer=server_completers[command_group], options_list=['--server-name', '-s'], help='Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.')

        with self.argument_context('{} server'.format(command_group)) as c:
            c.ignore('family', 'capacity', 'tier')

            c.argument('server_name', arg_type=server_name_arg_type, options_list=['--name', '-n'], id_part='name', help='Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.')
            c.argument('administrator_login', options_list=['--admin-user', '-u'], help='Administrator username for the server. Once set, it cannot be changed.')
            c.argument('administrator_login_password', options_list=['--admin-password', '-p'], help='The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.')
            c.argument('ssl_enforcement', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--ssl-enforcement'], help='Enable or disable ssl enforcement for connections to server. Default is Enabled.')
            c.argument('minimal_tls_version', arg_type=get_enum_type(['TLS1_0', 'TLS1_1', 'TLS1_2', 'TLSEnforcementDisabled']), options_list=['--minimal-tls-version'], help='Set the minimal TLS version for connections to server when SSL is enabled. Default is TLSEnforcementDisabled.', validator=tls_validator)
            c.argument('public_network_access', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--public-network-access', '--public'], help='Enable or disable public network access to server. When disabled, only connections made through Private Links can reach this server. Default is Enabled.')
            c.argument('tier', arg_type=get_enum_type(['Basic', 'GeneralPurpose', 'MemoryOptimized']), options_list=['--performance-tier'], help='The performance tier of the server.')
            c.argument('capacity', options_list=['--vcore'], type=int, help='Number of vcore.')
            c.argument('family', options_list=['--family'], arg_type=get_enum_type(['Gen4', 'Gen5']), help='Hardware generation.')
            c.argument('storage_mb', options_list=['--storage-size'], type=int, help='The storage capacity of the server (unit is megabytes). Minimum 5120 and increases in 1024 increments. Default is 51200.')
            c.argument('backup_retention', options_list=['--backup-retention'], type=int, help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.', validator=retention_validator)
            c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-grow'], help='Enable or disable autogrow of the storage. Default value is Enabled.')
            c.argument('infrastructure_encryption', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--infrastructure-encryption', '-i'], help='Add an optional second layer of encryption for data using new encryption algorithm. Default value is Disabled.')
            c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault.')
            c.argument('tags', tags_type)

            if command_group == 'mariadb':
                c.ignore('minimal_tls_version')
                c.ignore('assign_identity')
                c.ignore('infrastructure_encryption')

        with self.argument_context('{} server create'.format(command_group)) as c:
            c.argument('server_name', options_list=['--name', '-n'], arg_type=server_name_setter_arg_type)
            c.argument('sku_name', options_list=['--sku-name'], required=True, help='The name of the sku. Follows the convention {pricing tier}_{compute generation}_{vCores} in shorthand. Examples: B_Gen5_1, GP_Gen5_4, MO_Gen5_16. ')
            c.argument('administrator_login', required=True, arg_group='Authentication')
            c.argument('administrator_login_password', required=True, arg_group='Authentication')

            c.argument('backup_retention', type=int, options_list=['--backup-retention'], help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.', validator=retention_validator)
            c.argument('geo_redundant_backup', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--geo-redundant-backup'], help='Enable or disable geo-redundant backups. Default value is Disabled. Not supported in Basic pricing tier.')
            c.argument('storage_mb', options_list=['--storage-size'], type=int, help='The storage capacity of the server (unit is megabytes). Minimum 5120 and increases in 1024 increments. Default is 51200.')
            c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-grow'], help='Enable or disable autogrow of the storage. Default value is Enabled.')
            c.argument('infrastructure_encryption', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--infrastructure-encryption', '-i'], help='Add an optional second layer of encryption for data using new encryption algorithm. Default value is Disabled.')
            c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault.')

            c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
            c.argument('version', help='Server major version.')

        with self.argument_context('{} server update'.format(command_group)) as c:
            c.ignore('family', 'capacity', 'tier')
            c.argument('sku_name', options_list=['--sku-name'], help='The name of the sku. Follows the convention {pricing tier}_{compute generation}_{vCores} in shorthand. Examples: B_Gen5_1, GP_Gen5_4, MO_Gen5_16.')
            c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault.')

        with self.argument_context('{} server restore'. format(command_group)) as c:
            c.argument('server_name', options_list=['--name', '-n'], arg_type=overriding_none_arg_type)
            c.argument('source_server', options_list=['--source-server', '-s'], help='The name or resource ID of the source server to restore from.')
            c.argument('restore_point_in_time', options_list=['--restore-point-in-time', '--pitr-time'], help='The point in time to restore from (ISO8601 format), e.g., 2017-04-26T02:10:00+08:00')

        with self.argument_context('{} server georestore'. format(command_group)) as c:
            c.argument('location', arg_type=get_location_type(self.cli_ctx), required=True)
            c.argument('sku_name', options_list=['--sku-name'], required=False, help='The name of the sku. Defaults to sku of the source server. Follows the convention {pricing tier}_{compute generation}_{vCores} in shorthand. Examples: B_Gen5_1, GP_Gen5_4, MO_Gen5_16.')
            c.argument('source_server', options_list=['--source-server', '-s'], required=True, help='The name or ID of the source server to restore from.')
            c.argument('backup_retention', options_list=['--backup-retention'], type=int, help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.', validator=retention_validator)
            c.argument('geo_redundant_backup', options_list=['--geo-redundant-backup'], help='Enable or disable geo-redundant backups. Default value is Disabled. Not supported in Basic pricing tier.')

        with self.argument_context('{} server replica'.format(command_group)) as c:
            c.argument('server_name', options_list=['--name', '-n'], arg_type=overriding_none_arg_type)
            c.argument('source_server', options_list=['--source-server', '-s'], help='The name or resource ID of the master server to the create replica for.')
            c.argument('location', options_list=['--location', '-l'], help='Location. Values from: `az account list-locations`. If not provided, the create replica will be in the same location as the master server')
            c.argument('sku_name', options_list=['--sku-name'], help='The name of the sku. Follows the convention {pricing tier}_{compute generation}_{vCores} in shorthand. Examples: B_Gen5_1, GP_Gen5_4, MO_Gen5_16.')

        with self.argument_context('{} server configuration set'.format(command_group)) as c:
            c.argument('value', help='Value of the configuration. If not provided, configuration value will be set to default.', validator=configuration_value_validator)
            c.ignore('source')

        with self.argument_context('{} server wait'.format(command_group)) as c:
            c.ignore('created', 'deleted', 'updated')

        with self.argument_context('{} server delete'.format(command_group)) as c:
            c.argument('server_name', options_list=['--name', '-n'], arg_type=server_name_getter_arg_type)

        with self.argument_context('{} server-logs'.format(command_group)) as c:
            c.argument('file_name', options_list=['--name', '-n'], nargs='+', help='Space-separated list of log filenames on the server to download.')
            c.argument('max_file_size', type=int, help='The file size limitation to filter files.')
            c.argument('file_last_written', type=int, help='Integer in hours to indicate file last modify time, default value is 72.')
            c.argument('filename_contains', help='The pattern that file name should match.')

        with self.argument_context('{} db'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
            c.argument('database_name', options_list=['--name', '-n'])

        with self.argument_context('{} server firewall-rule'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'])
            c.argument('firewall_rule_name', options_list=['--name', '-n'], id_part='child_name_1', help='The name of the firewall rule. The firewall rule name cannot be empty. The firewall rule name can only contain 0-9, a-z, A-Z, \'-\' and \'_\'. Additionally, the firewall rule name cannot exceed 128 characters.')
            c.argument('start_ip_address', options_list=['--start-ip-address'], help='The start IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses.')
            c.argument('end_ip_address', options_list=['--end-ip-address'], help='The end IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses.')

        with self.argument_context('{} server vnet-rule'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'])
            c.argument('virtual_network_rule_name', options_list=['--name', '-n'], id_part='child_name_1', help='The name of the vnet rule.')
            c.argument('virtual_network_subnet_id', options_list=['--subnet'], help='Name or ID of the subnet that allows access to an Azure Postgres Server. If subnet name is provided, --vnet-name must be provided.')
            c.argument('ignore_missing_vnet_service_endpoint', options_list=['--ignore-missing-endpoint', '-i'], help='Create vnet rule before virtual network has vnet service endpoint enabled', arg_type=get_three_state_flag())

        with self.argument_context('{} server vnet-rule create'.format(command_group)) as c:
            c.extra('vnet_name', options_list=['--vnet-name'], help='The virtual network name', validator=validate_subnet)

        with self.argument_context('{} server vnet-rule update'.format(command_group)) as c:
            c.extra('vnet_name', options_list=['--vnet-name'], help='The virtual network name',
                    validator=validate_subnet)

        with self.argument_context('{} server configuration'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'])
            c.argument('configuration_name', id_part='child_name_1', options_list=['--name', '-n'])

        with self.argument_context('{} server replica list'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'], help='Name of the master server.')

        for item in ['approve', 'reject', 'delete', 'show']:
            with self.argument_context('{} server private-endpoint-connection {}'.format(command_group, item)) as c:
                c.argument('private_endpoint_connection_name', options_list=['--name', '-n'], required=False,
                           help='The name of the private endpoint connection associated with the Server. '
                                'Required if --id is not specified')
                c.extra('connection_id', options_list=['--id'], required=False,
                        help='The ID of the private endpoint connection associated with the Server. '
                             'If specified --server-name/-s and --name/-n, this should be omitted.')
                c.argument('server_name', options_list=['--server-name', '-s'], required=False,
                           help='Name of the Server. Required if --id is not specified')
                c.argument('resource_group_name', help='The resource group name of specified server.',
                           required=False)
                c.argument('description', help='Comments for {} operation.'.format(item))

        with self.argument_context('{} server private-link-resource'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'], required=True, help='Name of the Server.')

        if command_group != 'mariadb':
            with self.argument_context('{} server key'.format(command_group)) as c:
                c.argument('server_name', options_list=['--name', '-s'])
                c.argument('kid', options_list=['--kid', '-k'], help='The Azure Key Vault key identifier of the server key. An example key identifier is "https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"')

            with self.argument_context('{} server ad-admin'.format(command_group)) as c:
                c.argument('server_name', options_list=['--server-name', '-s'])
                c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Azure AD administrator user or group.')
                c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Azure AD administrator.')
예제 #6
0
    def _flexible_server_params(command_group):

        server_name_setter_arg_type = CLIArgumentType(metavar='NAME',
                                                      help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                                      local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        server_name_getter_arg_type = CLIArgumentType(metavar='NAME',
                                                      help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                                      local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.GET], scopes=['{} flexible-server'.format(command_group)]))

        server_name_arg_type = CLIArgumentType(metavar='NAME',
                                               help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
                                               local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET, LocalContextAction.GET], scopes=['{} flexible-server'.format(command_group)]))

        administrator_login_setter_arg_type = CLIArgumentType(metavar='NAME',
                                                              local_context_attribute=LocalContextAttribute(name='administrator_login', actions=[LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        administrator_login_arg_type = CLIArgumentType(metavar='NAME',
                                                       local_context_attribute=LocalContextAttribute(name='administrator_login', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        database_name_setter_arg_type = CLIArgumentType(metavar='NAME',
                                                        local_context_attribute=LocalContextAttribute(name='database_name', actions=[LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        database_name_getter_arg_type = CLIArgumentType(metavar='NAME',
                                                        local_context_attribute=LocalContextAttribute(name='database_name', actions=[LocalContextAction.GET], scopes=['{} flexible-server'.format(command_group)]))

        database_name_arg_type = CLIArgumentType(metavar='NAME',
                                                 local_context_attribute=LocalContextAttribute(name='database_name', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)]))

        overriding_none_arg_type = CLIArgumentType(local_context_attribute=LocalContextAttribute(name='context_name', actions=[LocalContextAction.GET]))

        with self.argument_context('{} flexible-server'.format(command_group)) as c:
            c.argument('server_name', id_part='name', options_list=['--name', '-n'], arg_type=server_name_arg_type)

        with self.argument_context('{} flexible-server create'.format(command_group)) as c:
            # Add create mode as a parameter
            if command_group == 'postgres':
                c.argument('tier', default='GeneralPurpose', options_list=['--tier'], validator=tier_validator,
                           help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
                c.argument('sku_name', default='Standard_D2s_v3', options_list=['--sku-name'], validator=pg_sku_name_validator,
                           help='The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_D4s_v3 ')
                c.argument('storage_mb', default='128', options_list=['--storage-size'], type=int, validator=pg_storage_validator,
                           help='The storage capacity of the server. Minimum is 32 GiB and max is 16 TiB.')
                c.argument('version', default='12', options_list=['--version'], validator=pg_version_validator,
                           help='Server major version.')
                c.argument('zone', options_list=['--zone, -z'],
                           help='Availability zone into which to provision the resource.')
            elif command_group == 'mysql':
                c.argument('tier', default='Burstable',
                           help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
                c.argument('sku_name', default='Standard_B1ms', options_list=['--sku-name'],
                           help='The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_B1ms, Standard_D4s_v3 ')
                c.argument('storage_mb', default='10', options_list=['--storage-size'], type=int, validator=mysql_storage_validator,
                           help='The storage capacity of the server. Minimum is 5 GiB and increases in 1 GiB increments. Max is 16 TiB.')
                c.argument('version', default='5.7', options_list=['--version'], validator=mysql_version_validator,
                           help='Server major version.')
                c.argument('zone', options_list=['--zone, -z'],
                           help='Availability zone into which to provision the resource.')

            c.argument('vnet_resource_id', options_list=['--vnet'], help='The virtual network name.')
            c.argument('vnet_address_prefix', options_list=['--address-prefixes'], help='The virtual network address prefix.')
            c.argument('subnet_address_prefix', options_list=['--subnet-prefixes'], help='The subnet address prefix.')
            c.argument('subnet_arm_resource_id', options_list=['--subnet'],
                       help='Name or ID of the subnet that allows access to an Azure Flexible Server. ')
            c.argument('server_name', options_list=['--name', '-n'], arg_type=server_name_setter_arg_type)
            c.argument('location', arg_type=get_location_type(self.cli_ctx))
            c.argument('administrator_login', default=generate_username(), options_list=['--admin-user, -u'], arg_group='Authentication', arg_type=administrator_login_setter_arg_type,
                       help='Administrator username for the server. Once set, it cannot be changed. ')
            c.argument('administrator_login_password', options_list=['--admin-password', '-p'],
                       help='The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.',
                       arg_group='Authentication')
            c.argument('backup_retention', default=7, type=int, options_list=['--backup-retention'],
                       help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.',
                       validator=retention_validator)
            c.argument('tags', tags_type)
            c.argument('public_access', options_list=['--public-access'],
                       help='Determines the public access. Enter single or range of IP addresses to be included in the allowed list of IPs. IP address ranges must be dash-separated and not contain any spaces. Specifying 0.0.0.0 allows public access from any resources deployed within Azure to access your server. Specifying no IP address sets the server in public access mode but does not create a firewall rule. ',
                       validator=public_access_validator)
            c.argument('high_availability', default="Disabled", options_list=['--high-availability'], help='Enable or disable high availability feature.  Default value is Disabled.')
            c.argument('assign_identity', options_list=['--assign-identity'],
                       help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault. No need to enter extra argument.')
            c.ignore('database_name')

        with self.argument_context('{} flexible-server delete'.format(command_group)) as c:
            c.argument('server_name', id_part='name', options_list=['--name', '-n'], arg_type=server_name_getter_arg_type)
            c.argument('force', options_list=['--force'], action='store_true',
                       help='Delete the server without prompt')

        with self.argument_context('{} flexible-server restore'.format(command_group)) as c:
            c.argument('server_name', options_list=['--name', '-n'], arg_type=overriding_none_arg_type,
                       help='The name of the new server that is created by the restore command.')
            c.argument('source_server', options_list=['--source-server'],
                       help='The name or resource ID of the source server to restore from.')
            c.argument('restore_point_in_time', options_list=['--time'],
                       help='The point in time to restore from (ISO8601 format), e.g., 2017-04-26T02:10:00+08:00')

        with self.argument_context('{} flexible-server update'.format(command_group)) as c:
            c.ignore('assign_identity')
            c.argument('backup_retention', type=int, options_list=['--backup-retention'],
                       help='The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.', validator=retention_validator)
            c.argument('administrator_login_password', options_list=['--admin-password', '-p'],
                       help='The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.',)
            c.argument('ha_enabled', options_list=['--high-availability'], arg_type=get_enum_type(['Enabled', 'Disabled']),
                       help='Enable or disable high availability feature.  Default value is Disabled.')
            c.argument('maintenance_window', options_list=['--maintenance-window'], validator=maintenance_window_validator,
                       help='Period of time (UTC) designated for maintenance. Examples: "Sun:23:30" to schedule on Sunday, 11:30pm UTC. To set back to default pass in "Disabled".')
            c.argument('tags', tags_type)
            if command_group == 'mysql':
                c.argument('tier', options_list=['--tier'],
                           help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
                c.argument('sku_name', options_list=['--sku-name'],
                           help='The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_B1ms, Standard_D4s_v3 ')
                c.argument('storage_mb', options_list=['--storage-size'], type=int,
                           validator=mysql_storage_validator,
                           help='The storage capacity of the server. Minimum is 5 GiB and increases in 1 GiB increments. Max is 16 TiB.')
                c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--storage-auto-grow'],
                           help='Enable or disable autogrow of the storage. Default value is Enabled.')
                c.argument('ssl_enforcement', arg_type=get_enum_type(['Enabled', 'Disabled']),
                           options_list=['--ssl-enforcement'],
                           help='Enable or disable ssl enforcement for connections to server. Default is Enabled.')
                c.argument('subnet_arm_resource_id', options_list=['--subnet'],
                           help='Name or ID of the subnet that allows access to an Azure Flexible Server MySQL Server. ')
                c.argument('replication_role', options_list=['--replication-role'],
                           help='The replication role of the server.')
            elif command_group == 'postgres':
                c.argument('tier', options_list=['--tier'], validator=tier_validator,
                           help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
                c.argument('sku_name', options_list=['--sku-name'], validator=pg_sku_name_validator,
                           help='The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_D4s_v3 ')
                c.argument('storage_mb', options_list=['--storage-size'], type=int,
                           validator=pg_storage_validator,
                           help='The storage capacity of the server. Minimum is 32 GiB and max is 16 TiB.')

        with self.argument_context('{} flexible-server list-skus'.format(command_group)) as c:
            c.argument('location', arg_type=get_location_type(self.cli_ctx))

        # flexible-server parameter
        for scope in ['list', 'set', 'show']:
            argument_context_string = '{} flexible-server parameter {}'.format(command_group, scope)
            with self.argument_context(argument_context_string) as c:
                if scope == "list":
                    c.argument('server_name', id_part=None, options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
                else:
                    c.argument('server_name', id_part='name', options_list=['--server-name', '-s'],
                               arg_type=server_name_arg_type)

        for scope in ['show', 'set']:
            argument_context_string = '{} flexible-server parameter {}'.format(command_group, scope)
            with self.argument_context(argument_context_string) as c:
                c.argument('configuration_name', id_part='child_name_1', options_list=['--name', '-n'], required=True,
                           help='The name of the server configuration')

        with self.argument_context('{} flexible-server parameter set'.format(command_group)) as c:
            c.argument('value', options_list=['--value', '-v'],
                       help='Value of the configuration.')
            c.argument('source', options_list=['--source'],
                       help='Source of the configuration.')

        # firewall-rule
        for scope in ['create', 'delete', 'list', 'show', 'update']:
            argument_context_string = '{} flexible-server firewall-rule {}'.format(command_group, scope)
            with self.argument_context(argument_context_string) as c:
                c.argument('resource_group_name', arg_type=resource_group_name_type)
                if scope == "list":
                    c.argument('server_name', id_part=None, options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
                else:
                    c.argument('server_name', id_part='name', options_list=['--server-name', '-s'], arg_type=server_name_arg_type)

        for scope in ['create', 'delete', 'show', 'update']:
            argument_context_string = '{} flexible-server firewall-rule {}'.format(command_group, scope)
            with self.argument_context(argument_context_string) as c:
                c.argument('firewall_rule_name', id_part='child_name_1', options_list=['--name', '-n'],
                           help='The name of the firewall rule. If name is omitted, default name will be chosen for firewall name. The firewall rule name can only contain 0-9, a-z, A-Z, \'-\' and \'_\'. Additionally, the firewall rule name cannot exceed 128 characters. ')

        with self.argument_context('{} flexible-server firewall-rule create'.format(command_group)) as c:
            c.argument('end_ip_address', options_list=['--end-ip-address'], validator=ip_address_validator,
                       help='The end IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses. ')
            c.argument('start_ip_address', options_list=['--start-ip-address'], validator=ip_address_validator,
                       help='The start IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses. ')

        with self.argument_context('{} flexible-server firewall-rule delete'.format(command_group)) as c:
            c.argument('prompt', options_list=['--prompt'], help='Turn confirmation prompt on/off. If off, the rule will be deleted without confirmation')

        with self.argument_context('{} flexible-server firewall-rule update'.format(command_group)) as c:
            c.argument('end_ip_address', options_list=['--end-ip-address'], validator=ip_address_validator,
                       help='When using \'set\' or \'add\', preserve string literals instead of attempting to convert to JSON.')
            c.argument('start_ip_address', options_list=['--start-ip-address'], validator=ip_address_validator,
                       help='The start IP address of the firewall rule. Must be IPv4 format. Use value \'0.0.0.0\' to represent all Azure-internal IP addresses. ')

        # db
        if command_group == "mysql":
            with self.argument_context('{} flexible-server db'.format(command_group)) as c:
                c.argument('server_name', options_list=['--server-name', '-s'], help='Name of the server.')
                c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')

            with self.argument_context('{} flexible-server db create'.format(command_group)) as c:
                c.argument('database_name', arg_type=database_name_setter_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')

            with self.argument_context('{} flexible-server db list'.format(command_group)) as c:
                c.argument('server_name', id_part=None, options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
                c.argument('database_name', id_part=None, arg_type=database_name_setter_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')

            with self.argument_context('{} flexible-server db delete'.format(command_group)) as c:
                c.argument('database_name', arg_type=database_name_getter_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
                c.argument('force', options_list=['--force'], action='store_true', help='Delete the database without prompt')

        with self.argument_context('{} flexible-server show-connection-string'.format(command_group)) as c:
            c.argument('server_name', options_list=['--server-name', '-s'], arg_type=server_name_arg_type, help='Name of the server.')
            c.argument('administrator_login', arg_type=administrator_login_arg_type, options_list=['--admin-user', '-u'],
                       help='The login username of the administrator.')
            c.argument('administrator_login_password', options_list=['--admin-password', '-p'],
                       help='The login password of the administrator.')
            c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')

        with self.argument_context('{} flexible-server replica list'.format(command_group)) as c:
            c.argument('server_name', id_part=None, options_list=['--name', '-s'], help='Name of the server.')

        with self.argument_context('{} flexible-server replica create'.format(command_group)) as c:
            c.argument('source_server', options_list=['--source-server'],
                       help='The name or resource ID of the source server to restore from.')
            if command_group == 'mysql':
                c.argument('tier', options_list=['--tier'],
                           help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')
                c.argument('sku_name', options_list=['--sku-name'],
                           help='The name of the compute SKU. Follows the convention'
                                ' Standard_{VM name}. Examples: Standard_B1ms, Standard_D4s_v3 ')
            if command_group == 'postgres':
                c.argument('tier', options_list=['--tier'], validator=tier_validator,
                           help='Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized ')

        with self.argument_context('{} flexible-server replica stop-replication'.format(command_group)) as c:
            c.argument('server_name', options_list=['--name', '-s'], help='Name of the server.')
예제 #7
0
def load_arguments(self, _):  # pylint: disable=too-many-locals, too-many-statements
    from argcomplete.completers import FilesCompleter
    from knack.arguments import CLIArgumentType
    from azure.cli.core.commands.parameters import get_resource_name_completion_list

    from .sdkutil import get_table_data_type
    from .completers import get_storage_name_completion_list, get_container_name_completions

    t_base_blob_service = self.get_sdk('blob.baseblobservice#BaseBlobService')
    t_file_service = self.get_sdk('file#FileService')
    t_table_service = get_table_data_type(self.cli_ctx, 'table', 'TableService')

    acct_name_type = CLIArgumentType(options_list=['--account-name', '-n'], help='The storage account name.',
                                     id_part='name',
                                     completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'),
                                     local_context_attribute=LocalContextAttribute(
                                         name='storage_account_name', actions=[LocalContextAction.GET]))
    blob_name_type = CLIArgumentType(options_list=['--blob-name', '-b'], help='The blob name.',
                                     completer=get_storage_name_completion_list(t_base_blob_service, 'list_blobs',
                                                                                parent='container_name'))
    container_name_type = CLIArgumentType(options_list=['--container-name', '-c'], help='The container name.',
                                          completer=get_container_name_completions)
    directory_path_type = CLIArgumentType(options_list=['--directory-path', '-d'], help='The directory path name.',
                                          parent='container_name')
    share_name_type = CLIArgumentType(options_list=['--share-name', '-s'], help='The file share name.',
                                      completer=get_storage_name_completion_list(t_file_service, 'list_shares'))
    table_name_type = CLIArgumentType(options_list=['--table-name', '-t'],
                                      completer=get_storage_name_completion_list(t_table_service, 'list_tables'))
    num_results_type = CLIArgumentType(
        default=5000, help='Specifies the maximum number of results to return. Provide "*" to return all.',
        validator=validate_storage_data_plane_list)
    acl_type = CLIArgumentType(options_list=['--acl-spec', '-a'],
                               help='The ACL specification to set on the path in the format '
                                    '"[default:]user|group|other|mask:[entity id or UPN]:r|-w|-x|-,'
                                    '[default:]user|group|other|mask:[entity id or UPN]:r|-w|-x|-,...". '
                                    'e.g."user::rwx,user:john.doe@contoso:rwx,group::r--,other::---,mask::rwx".')

    with self.argument_context('storage') as c:
        c.argument('container_name', container_name_type)
        c.argument('share_name', share_name_type)
        c.argument('table_name', table_name_type)
        c.argument('retry_wait', options_list=('--retry-interval',))
        c.ignore('progress_callback')
        c.argument('metadata', nargs='+',
                   help='Metadata in space-separated key=value pairs. This overwrites any existing metadata.',
                   validator=validate_metadata)
        c.argument('timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

    with self.argument_context('storage', arg_group='Precondition') as c:
        c.argument('if_modified_since', help='Alter only if modified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')',
                   type=get_datetime_type(False))
        c.argument('if_unmodified_since',
                   help='Alter only if unmodified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')',
                   type=get_datetime_type(False))
        c.argument('if_match')
        c.argument('if_none_match')

    with self.argument_context('storage account blob-inventory-policy') as c:
        c.ignore('blob_inventory_policy_name')
        c.argument('resource_group_name', required=False, validator=process_resource_group)
        c.argument('account_name',
                   help='The name of the storage account within the specified resource group. Storage account names '
                        'must be between 3 and 24 characters in length and use numbers and lower-case letters only.')

    with self.argument_context('storage account blob-inventory-policy create') as c:
        # t_inventory_rule_type = self.get_models('InventoryRuleType', resource_type=CUSTOM_MGMT_PREVIEW_STORAGE)
        c.argument('policy', type=file_type, completer=FilesCompleter(),
                   help='The Storage Account Blob Inventory Policy, string in JSON format or json file path. '
                        'See more details in: {https://review.docs.microsoft.com/en-us/azure/storage/blobs/'
                        'blob-inventory?branch=pr-en-us-135665}.')
        # c.argument('destination',
        #            help='Container name where blob inventory files are stored. Must be pre-created.')
        # c.argument('enabled', arg_type=get_three_state_flag(), help='Policy is enabled if set to true.')
        # c.argument('type', arg_type=get_enum_type(t_inventory_rule_type), default='Inventory', required=False,
        #            help='The valid value is Inventory. Possible values include: "Inventory".')
        # c.argument('rule_name', arg_group='Blob Inventory Policy Rule',
        #            help='A rule name can contain any combination of alpha numeric characters. Rule name is '
        #            'case-sensitive. It must be unique within a policy.')
        # c.argument('prefix_match', arg_group='Blob Inventory Policy Rule', nargs='+',
        #            help='An array of strings for blob prefixes to be matched.')
        # c.argument('blob_types', arg_group='Blob Inventory Policy Rule', nargs='+',
        #            help='An array of predefined enum values. Valid values include blockBlob, appendBlob, pageBlob. '
        #                 'Hns accounts does not support pageBlobs.')
        # c.argument('include_blob_versions', arg_group='Blob Inventory Policy Rule', arg_type=get_three_state_flag(),
        #            help='Include blob versions in blob inventory when value set to true.')
        # c.argument('include_snapshots', arg_group='Blob Inventory Policy Rule', arg_type=get_three_state_flag(),
        #            help='Include blob snapshots in blob inventory when value set to true.')

    # with self.argument_context('storage account blob-inventory-policy rule') as c:
    #     c.argument('destination', help='')
    #     c.argument('enabled', help='')
    #     c.argument('type', help='')

    with self.argument_context('storage account network-rule') as c:
        from ._validators import validate_subnet
        c.argument('account_name', acct_name_type, id_part=None)
        c.argument('ip_address', help='IPv4 address or CIDR range.')
        c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
        c.argument('vnet_name', help='Name of a virtual network.', validator=validate_subnet)
        c.argument('action', help='The action of virtual network rule.')
        c.argument('resource_id', help='The resource id to add in network rule.')
        c.argument('tenant_id', help='The tenant id to add in network rule.')

    with self.argument_context('storage blob service-properties update') as c:
        c.argument('delete_retention', arg_type=get_three_state_flag(), arg_group='Soft Delete',
                   help='Enables soft-delete.')
        c.argument('days_retained', type=int, arg_group='Soft Delete',
                   help='Number of days that soft-deleted blob will be retained. Must be in range [1,365].')
        c.argument('static_website', arg_group='Static Website', arg_type=get_three_state_flag(),
                   help='Enables static-website.')
        c.argument('index_document', help='Represents the name of the index document. This is commonly "index.html".',
                   arg_group='Static Website')
        c.argument('error_document_404_path', options_list=['--404-document'], arg_group='Static Website',
                   help='Represents the path to the error document that should be shown when an error 404 is issued,'
                        ' in other words, when a browser requests a page that does not exist.')

    with self.argument_context('storage azcopy blob upload') as c:
        c.extra('destination_container', options_list=['--container', '-c'], required=True,
                help='The upload destination container.')
        c.extra('destination_path', options_list=['--destination', '-d'],
                validator=validate_azcopy_upload_destination_url,
                help='The upload destination path.')
        c.argument('source', options_list=['--source', '-s'],
                   help='The source file path to upload from.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively upload blobs.')
        c.ignore('destination')

    with self.argument_context('storage azcopy blob download') as c:
        c.extra('source_container', options_list=['--container', '-c'], required=True,
                help='The download source container.')
        c.extra('source_path', options_list=['--source', '-s'],
                validator=validate_azcopy_download_source_url,
                help='The download source path.')
        c.argument('destination', options_list=['--destination', '-d'],
                   help='The destination file path to download to.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively download blobs.')
        c.ignore('source')

    with self.argument_context('storage azcopy blob delete') as c:
        c.extra('target_container', options_list=['--container', '-c'], required=True,
                help='The delete target container.')
        c.extra('target_path', options_list=['--target', '-t'],
                validator=validate_azcopy_target_url,
                help='The delete target path.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively delete blobs.')
        c.ignore('target')

    with self.argument_context('storage azcopy blob sync') as c:
        c.extra('destination_container', options_list=['--container', '-c'], required=True,
                help='The sync destination container.')
        c.extra('destination_path', options_list=['--destination', '-d'],
                validator=validate_azcopy_upload_destination_url,
                help='The sync destination path.')
        c.argument('source', options_list=['--source', '-s'],
                   help='The source file path to sync from.')
        c.ignore('destination')

    with self.argument_context('storage azcopy run-command') as c:
        c.positional('command_args', help='Command to run using azcopy. Please start commands with "azcopy ".')

    with self.argument_context('storage blob access') as c:
        c.argument('path', blob_name_type)

    with self.argument_context('storage blob access set') as c:
        c.argument('acl', acl_type, required=True,)
        c.ignore('owner', 'group', 'permissions')

    with self.argument_context('storage blob access update') as c:
        c.argument('acl', acl_type)
        c.argument('owner', help='The owning user for the directory.')
        c.argument('group', help='The owning group for the directory.')
        c.argument('permissions', help='The POSIX access permissions for the file owner,'
                   'the file owning group, and others. Both symbolic (rwxrw-rw-) and 4-digit '
                   'octal notation (e.g. 0766) are supported.')

    with self.argument_context('storage blob list') as c:
        c.argument('include', validator=validate_included_datasets, default='mc')
        c.argument('num_results', arg_type=num_results_type)

    with self.argument_context('storage blob move') as c:
        from ._validators import validate_move_file
        c.argument('source_path', options_list=['--source-blob', '-s'], validator=validate_move_file,
                   help="The source blob name. It should be an absolute path under the container. e.g."
                        "'topdir1/dirsubfoo'.")
        c.argument('new_path', options_list=['--destination-blob', '-d'],
                   help="The destination blob name. It should be an absolute path under the container. e.g."
                        "'topdir1/dirbar'.")
        c.argument('container_name', container_name_type)
        c.ignore('mode')
        c.ignore('marker')

    with self.argument_context('storage blob directory') as c:
        c.argument('directory_path', directory_path_type)
        c.argument('container_name', container_name_type)

    with self.argument_context('storage blob directory access') as c:
        c.argument('path', directory_path_type)

    with self.argument_context('storage blob directory access set') as c:
        c.argument('acl', acl_type, required=True)
        c.ignore('owner', 'group', 'permissions')

    with self.argument_context('storage blob directory access update') as c:
        c.argument('acl', acl_type)
        c.argument('owner', help='The owning user for the directory.')
        c.argument('group', help='The owning group for the directory.')
        c.argument('permissions', help='The POSIX access permissions for the file owner,'
                   'the file owning group, and others. Both symbolic (rwxrw-rw-) and 4-digit '
                   'octal notation (e.g. 0766) are supported.')

    with self.argument_context('storage blob directory create') as c:
        from ._validators import validate_directory_name
        c.argument('posix_permissions', options_list=['--permissions'])
        c.argument('posix_umask', options_list=['--umask'], default='0027',
                   help='Optional and only valid if Hierarchical Namespace is enabled for the account. '
                        'The umask restricts permission settings for file and directory, and will only be applied when '
                        'default Acl does not exist in parent directory. If the umask bit has set, it means that the '
                        'corresponding permission will be disabled. In this way, the resulting permission is given by '
                        'p & ^u, where p is the permission and u is the umask. Only 4-digit octal notation (e.g. 0022) '
                        'is supported here.')
        c.argument('directory_path', directory_path_type, validator=validate_directory_name)

    with self.argument_context('storage blob directory download') as c:
        c.extra('source_container', options_list=['--container', '-c'], required=True,
                help='The download source container.')
        c.extra('source_path', options_list=['--source-path', '-s'], required=True,
                validator=validate_blob_directory_download_source_url,
                help='The download source directory path. It should be an absolute path to container.')
        c.argument('destination', options_list=['--destination-path', '-d'],
                   help='The destination local directory path to download.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively download blobs. If enabled, all the blobs including the blobs in subdirectories '
                        'will be downloaded.')
        c.ignore('source')

    with self.argument_context('storage blob directory exists') as c:
        c.argument('blob_name', directory_path_type, required=True)

    with self.argument_context('storage blob directory list') as c:
        c.argument('include', validator=validate_included_datasets, default='mc')
        c.argument('num_results', arg_type=num_results_type)

    with self.argument_context('storage blob directory metadata') as c:
        c.argument('blob_name', directory_path_type)

    with self.argument_context('storage blob directory move') as c:
        from ._validators import validate_move_directory
        c.argument('new_path', options_list=['--destination-path', '-d'],
                   help='The destination blob directory path. It can be a directory or subdirectory name, e.g. dir, '
                        'dir/subdir. If the destination path exists and is empty, the source will be moved into the '
                        'destination path. If the destination path does not exist, the destination path will be created'
                        ' and overwritten by the source. To control the move operation for nonempty path, you can use '
                        '--move-mode to determine its behavior.')
        c.argument('source_path', options_list=['--source-path', '-s'],
                   help='The source blob directory path.', validator=validate_move_directory)
        c.argument('lease_id', options_list=['--lease-id'],
                   help='A lease ID for destination directory_path. The destination directory_path must have an active '
                        'lease and the lease ID must match.')
        c.argument('mode', options_list=['--move-mode'], arg_type=get_enum_type(["legacy", "posix"]), default="posix",
                   help="Valid only when namespace is enabled. This parameter determines the behavior "
                        "of the move operation. If the destination directory is empty, for both two mode, "
                        "the destination directory will be overwritten. But if the destination directory is not empty, "
                        "in legacy mode the move operation will fail and in posix mode, the source directory will be "
                        "moved into the destination directory. ")

    with self.argument_context('storage blob directory show') as c:
        c.argument('directory_name', directory_path_type)
        c.argument('container_name', container_name_type)
        # c.argument('snapshot', help='The snapshot parameter is an opaque DateTime value that, '
        #                            'when present, specifies the directory snapshot to retrieve.')
        c.ignore('snapshot')
        c.argument('lease_id', help='Required if the blob has an active lease.')
        c.argument('if_match', help="An ETag value, or the wildcard character (*). Specify this header to perform the"
                   "operation only if the resource's ETag matches the value specified")
        c.argument('if_none_match', help="An ETag value, or the wildcard character (*). Specify this header to perform"
                   "the operation only if the resource's ETag does not match the value specified. Specify the wildcard"
                   "character (*) to perform the operation only if the resource does not exist, and fail the operation"
                   "if it does exist.")

    with self.argument_context('storage blob directory upload') as c:
        c.extra('destination_container', options_list=['--container', '-c'], required=True,
                help='The upload destination container.')
        c.extra('destination_path', options_list=['--destination-path', '-d'], required=True,
                validator=validate_blob_directory_upload_destination_url,
                help='The upload destination directory path. It should be an absolute path to container. If the '
                     'specified destination path does not exist, a new directory path will be created.')
        c.argument('source', options_list=['--source', '-s'],
                   help='The source file path to upload from.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively upload blobs. If enabled, all the blobs including the blobs in subdirectories will'
                        ' be uploaded.')
        c.ignore('destination')
예제 #8
0
def load_arguments(self, _):
    webapp_name_arg_type = CLIArgumentType(
        configured_default='web',
        options_list=['--name', '-n'],
        metavar='NAME',
        completer=get_resource_name_completion_list('Microsoft.Web/sites'),
        id_part='name',
        help="name of the web app.",
        local_context_attribute=LocalContextAttribute(
            name='web_name', actions=[LocalContextAction.GET]))

    with self.argument_context('webapp auth') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument(
            'slot',
            options_list=['--slot', '-s'],
            help=
            "the name of the slot. Default to the productions slot if not specified"
        )
        c.argument('name', arg_type=webapp_name_arg_type)

    with self.argument_context('webapp auth-classic') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument(
            'slot',
            options_list=['--slot', '-s'],
            help=
            "the name of the slot. Default to the productions slot if not specified"
        )
        c.argument('name', arg_type=webapp_name_arg_type)

    with self.argument_context('webapp auth set') as c:
        c.argument(
            'body',
            options_list=['--body', '-b'],
            help=
            'JSON representation of the configuration settings for the Azure App Service Authentication / Authorization V2 feature.'
        )

    with self.argument_context('webapp auth update') as c:
        c.argument(
            'set_string',
            options_list=['--set'],
            help=
            'Value of a specific field within the configuration settings for the Azure App Service Authentication / Authorization V2 feature.'
        )
        c.argument(
            'enabled',
            options_list=['--enabled'],
            arg_type=get_three_state_flag(return_label=True),
            help=
            'true if the Authentication / Authorization feature is enabled for the current app; otherwise, false.'
        )
        c.argument(
            'runtime_version',
            options_list=['--runtime-version'],
            help=
            'The RuntimeVersion of the Authentication / Authorization feature in use for the current app.'
        )
        c.argument(
            'config_file_path',
            options_list=['--config-file-path'],
            help=
            'The path of the config file containing auth settings if they come from a file.'
        )
        c.argument(
            'unauthenticated_client_action',
            options_list=['--unauthenticated-client-action', '--action'],
            arg_type=get_enum_type(UNAUTHENTICATED_CLIENT_ACTION),
            help=
            'The action to take when an unauthenticated client attempts to access the app.'
        )
        c.argument(
            'redirect_provider',
            options_list=['--redirect-provider'],
            help=
            'The default authentication provider to use when multiple providers are configured.'
        )
        c.argument(
            'enable_token_store',
            options_list=['--enable-token-store'],
            arg_type=get_three_state_flag(return_label=True),
            help=
            'true to durably store platform-specific security tokens that are obtained during login flows; otherwise, false.'
        )
        c.argument(
            'require_https',
            options_list=['--require-https'],
            arg_type=get_three_state_flag(return_label=True),
            help=
            'false if the authentication/authorization responses not having the HTTPS scheme are permissible; otherwise, true.'
        )
        c.argument(
            'proxy_convention',
            options_list=['--proxy-convention'],
            arg_type=get_enum_type(FORWARD_PROXY_CONVENTION),
            help='The convention used to determine the url of the request made.'
        )
        c.argument(
            'proxy_custom_host_header',
            options_list=[
                '--proxy-custom-host-header', '--custom-host-header'
            ],
            help='The name of the header containing the host of the request.')
        c.argument(
            'proxy_custom_proto_header',
            options_list=[
                '--proxy-custom-proto-header', '--custom-proto-header'
            ],
            help='The name of the header containing the scheme of the request.'
        )
        c.argument(
            'excluded_paths',
            options_list=['--excluded-paths'],
            help=
            'The list of paths that should be excluded from authentication rules.'
        )

    with self.argument_context('webapp auth microsoft update') as c:
        c.argument(
            'client_id',
            options_list=['--client-id'],
            help=
            'The Client ID of this relying party application, known as the client_id.'
        )
        c.argument('client_secret',
                   options_list=['--client-secret'],
                   help='AAD application secret')
        c.argument(
            'client_secret_setting_name',
            options_list=['--client-secret-setting-name', '--secret-setting'],
            help=
            'The app setting name that contains the client secret of the relying party application.'
        )
        c.argument(
            'issuer',
            options_list=['--issuer'],
            help=
            'The OpenID Connect Issuer URI that represents the entity which issues access tokens for this application.'
        )
        c.argument(
            'allowed_token_audiences',
            options_list=['--allowed-token-audiences', '--allowed-audiences'],
            help=
            'The configuration settings of the allowed list of audiences from which to validate the JWT token.'
        )
        c.argument(
            'client_secret_certificate_thumbprint',
            options_list=[
                '--thumbprint', '--client-secret-certificate-thumbprint'
            ],
            help=
            'Alternative to AAD Client Secret, thumbprint of a certificate used for signing purposes'
        )
        c.argument(
            'client_secret_certificate_san',
            options_list=['--san', '--client-secret-certificate-san'],
            help=
            'Alternative to AAD Client Secret and thumbprint, subject alternative name of a certificate used for signing purposes'
        )
        c.argument(
            'client_secret_certificate_issuer',
            options_list=[
                '--certificate-issuer', '--client-secret-certificate-issuer'
            ],
            help=
            'Alternative to AAD Client Secret and thumbprint, issuer of a certificate used for signing purposes'
        )
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')
        c.argument('tenant_id',
                   options_list=['--tenant-id'],
                   help='The tenant id of the application.')

    with self.argument_context('webapp auth facebook update') as c:
        c.argument('app_id',
                   options_list=['--app-id'],
                   help='The App ID of the app used for login.')
        c.argument('app_secret',
                   options_list=['--app-secret'],
                   help='The app secret.')
        c.argument(
            'app_secret_setting_name',
            options_list=['--app-secret-setting-name', '--secret-setting'],
            help='The app setting name that contains the app secret.')
        c.argument(
            'graph_api_version',
            options_list=['--graph-api-version'],
            help='The version of the Facebook api to be used while logging in.'
        )
        c.argument(
            'scopes',
            options_list=['--scopes'],
            help=
            'A list of the scopes that should be requested while authenticating.'
        )
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth github update') as c:
        c.argument('client_id',
                   options_list=['--client-id'],
                   help='The Client ID of the app used for login.')
        c.argument(
            'client_secret_setting_name',
            options_list=['--client-secret-setting-name', '--secret-setting'],
            help='The app setting name that contains the client secret.')
        c.argument('client_secret',
                   options_list=['--client-secret'],
                   help='The client secret.')
        c.argument(
            'scopes',
            options_list=['--scopes'],
            help=
            'A list of the scopes that should be requested while authenticating.'
        )
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth google update') as c:
        c.argument('client_id',
                   options_list=['--client-id'],
                   help='The Client ID of the app used for login.')
        c.argument('client_secret',
                   options_list=['--client-secret'],
                   help='The client secret.')
        c.argument(
            'client_secret_setting_name',
            options_list=['--client-secret-setting-name', '--secret-setting'],
            help='The app setting name that contains the client secret.')
        c.argument(
            'scopes',
            options_list=['--scopes'],
            help=
            'A list of the scopes that should be requested while authenticating.'
        )
        c.argument(
            'allowed_token_audiences',
            options_list=['--allowed-token-audiences', '--allowed-audiences'],
            help=
            'The configuration settings of the allowed list of audiences from which to validate the JWT token.'
        )
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth twitter update') as c:
        c.argument(
            'consumer_key',
            options_list=['--consumer-key'],
            help=
            'The OAuth 1.0a consumer key of the Twitter application used for sign-in.'
        )
        c.argument('consumer_secret',
                   options_list=['--consumer-secret'],
                   help='The consumer secret.')
        c.argument(
            'consumer_secret_setting_name',
            options_list=[
                '--consumer-secret-setting-name', '--secret-setting'
            ],
            help=
            'The app setting name that contains the OAuth 1.0a consumer secret of the Twitter.'
        )
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth apple update') as c:
        c.argument('client_id',
                   options_list=['--client-id'],
                   help='The Client ID of the app used for login.')
        c.argument('client_secret',
                   options_list=['--client-secret'],
                   help='The client secret.')
        c.argument(
            'client_secret_setting_name',
            options_list=['--client-secret-setting-name', '--secret-setting'],
            help='The app setting name that contains the client secret.')
        c.argument(
            'scopes',
            options_list=['--scopes'],
            help=
            'A list of the scopes that should be requested while authenticating.'
        )
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth openid-connect show') as c:
        c.argument('provider_name',
                   options_list=['--provider-name'],
                   required=True,
                   help='The name of the custom OpenID Connect provider.')

    with self.argument_context('webapp auth openid-connect add') as c:
        c.argument('provider_name',
                   options_list=['--provider-name'],
                   required=True,
                   help='The name of the custom OpenID Connect provider.')
        c.argument('client_id',
                   options_list=['--client-id'],
                   help='The Client ID of the app used for login.')
        c.argument(
            'client_secret_setting_name',
            options_list=['--client-secret-setting-name', '--secret-setting'],
            help='The app setting name that contains the client secret.')
        c.argument(
            'openid_configuration',
            options_list=['--openid-configuration'],
            help=
            'The endpoint that contains all the configuration endpoints for the provider.'
        )
        c.argument(
            'scopes',
            options_list=['--scopes'],
            help=
            'A list of the scopes that should be requested while authenticating.'
        )
        c.argument('client_secret',
                   options_list=['--client-secret'],
                   help='The application secret of the app used for login.')
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth openid-connect update') as c:
        c.argument('provider_name',
                   options_list=['--provider-name'],
                   required=True,
                   help='The name of the custom OpenID Connect provider.')
        c.argument('client_id',
                   options_list=['--client-id'],
                   help='The Client ID of the app used for login.')
        c.argument(
            'client_secret_setting_name',
            options_list=['--client-secret-setting-name', '--secret-setting'],
            help='The app setting name that contains the client secret.')
        c.argument(
            'openid_configuration',
            options_list=['--openid-configuration'],
            help=
            'The endpoint that contains all the configuration endpoints for the provider.'
        )
        c.argument(
            'scopes',
            options_list=['--scopes'],
            help=
            'A list of the scopes that should be requested while authenticating.'
        )
        c.argument('client_secret',
                   options_list=['--client-secret'],
                   help='The application secret of the app used for login.')
        c.argument('yes',
                   options_list=['--yes', '-y'],
                   help='Do not prompt for confirmation.',
                   action='store_true')

    with self.argument_context('webapp auth openid-connect remove') as c:
        c.argument('provider_name',
                   options_list=['--provider-name'],
                   required=True,
                   help='The name of the custom OpenID Connect provider.')

    with self.argument_context('webapp auth-classic update') as c:
        c.argument(
            'enabled',
            arg_type=get_three_state_flag(return_label=True),
            help=
            'true if the Authentication / Authorization feature is enabled for the current app; otherwise, false.'
        )
        c.argument('token_store_enabled',
                   options_list=['--token-store'],
                   arg_type=get_three_state_flag(return_label=True),
                   help='use App Service Token Store')
        c.argument(
            'action',
            arg_type=get_enum_type(AUTH_TYPES),
            help=
            'The action to take when an unauthenticated client attempts to access the app.'
        )
        c.argument(
            'runtime_version',
            help=
            'Runtime version of the Authentication/Authorization feature in use for the current app'
        )
        c.argument('token_refresh_extension_hours',
                   type=float,
                   options_list=[
                       '--token-refresh-extension-hours',
                       '--token-refresh-hours'
                   ],
                   help="Hours, must be formattable into a float")
        c.argument('allowed_external_redirect_urls',
                   options_list=['--allowed-redirect-urls'],
                   nargs='+',
                   help="One or more urls (space-delimited).")
        c.argument(
            'client_id',
            options_list=['--aad-client-id'],
            arg_group='Azure Active Directory',
            help=
            'Application ID to integrate AAD organization account Sign-in into your web app'
        )
        c.argument('client_secret',
                   options_list=['--aad-client-secret'],
                   arg_group='Azure Active Directory',
                   help='AAD application secret')
        c.argument(
            'client_secret_setting_name',
            options_list=[
                '--aad-client-secret-setting-name', '--aad-secret-setting'
            ],
            arg_group='Azure Active Directory',
            help=
            'The app setting name that contains the client secret of the relying party application.'
        )
        c.argument(
            'client_secret_certificate_thumbprint',
            options_list=[
                '--aad-client-secret-certificate-thumbprint', '--thumbprint'
            ],
            arg_group='Azure Active Directory',
            help=
            'Alternative to AAD Client Secret, thumbprint of a certificate used for signing purposes'
        )
        c.argument('allowed_audiences',
                   nargs='+',
                   options_list=[
                       '--aad-allowed-token-audiences', '--allowed-audiences'
                   ],
                   arg_group='Azure Active Directory',
                   help="One or more token audiences (space-delimited).")
        c.argument(
            'issuer',
            options_list=['--aad-token-issuer-url'],
            help=
            'This url can be found in the JSON output returned from your active directory endpoint using your tenantID. The endpoint can be queried from `az cloud show` at \"endpoints.activeDirectory\". '
            'The tenantID can be found using `az account show`. Get the \"issuer\" from the JSON at <active directory endpoint>/<tenantId>/.well-known/openid-configuration.',
            arg_group='Azure Active Directory')
        c.argument(
            'facebook_app_id',
            arg_group='Facebook',
            help=
            "Application ID to integrate Facebook Sign-in into your web app")
        c.argument('facebook_app_secret',
                   arg_group='Facebook',
                   help='Facebook Application client secret')
        c.argument(
            'facebook_app_secret_setting_name',
            arg_group='Facebook',
            options_list=[
                '--facebook-app-secret-setting-name', '--fb-secret-setting'
            ],
            help=
            'The app setting name that contains the app secret used for Facebook Login.'
        )
        c.argument(
            'facebook_oauth_scopes',
            nargs='+',
            help=
            "One or more facebook authentication scopes (space-delimited).",
            arg_group='Facebook')
        c.argument(
            'twitter_consumer_key',
            arg_group='Twitter',
            help='Application ID to integrate Twitter Sign-in into your web app'
        )
        c.argument(
            'twitter_consumer_secret',
            arg_group='Twitter',
            options_list=['--twitter-consumer-secret', '--twitter-secret'],
            help='Twitter Application client secret')
        c.argument(
            'twitter_consumer_secret_setting_name',
            arg_group='Twitter',
            options_list=[
                '--twitter-consumer-secret-setting-name',
                '--twitter-secret-setting'
            ],
            help=
            'The app setting name that contains the OAuth 1.0a consumer secret of the Twitter application used for sign-in.'
        )
        c.argument(
            'google_client_id',
            arg_group='Google',
            help='Application ID to integrate Google Sign-in into your web app'
        )
        c.argument('google_client_secret',
                   arg_group='Google',
                   help='Google Application client secret')
        c.argument(
            'google_client_secret_setting_name',
            arg_group='Google',
            options_list=[
                '--google-client-secret-setting-name',
                '--google-secret-setting'
            ],
            help=
            'The app setting name that contains the client secret associated with the Google web application.'
        )
        c.argument(
            'google_oauth_scopes',
            nargs='+',
            help="One or more Google authentication scopes (space-delimited).",
            arg_group='Google')
        c.argument(
            'microsoft_account_client_id',
            arg_group='Microsoft',
            options_list=['--microsoft-account-client-id', '--msa-client'],
            help=
            "AAD V2 Application ID to integrate Microsoft account Sign-in into your web app"
        )
        c.argument(
            'microsoft_account_client_secret',
            arg_group='Microsoft',
            options_list=['--microsoft-account-client-secret', '--msa-secret'],
            help='AAD V2 Application client secret')
        c.argument(
            'microsoft_account_client_secret_setting_name',
            arg_group='Microsoft',
            options_list=[
                '--microsoft-account-client-secret-setting-name',
                '--msa-secret-setting'
            ],
            help=
            'The app setting name containing the OAuth 2.0 client secret that was created for the app used for authentication.'
        )
        c.argument(
            'microsoft_account_oauth_scopes',
            nargs='+',
            options_list=['--microsoft-account-oauth-scopes', '--msa-scopes'],
            help=
            "One or more Microsoft authentification scopes (space-delimited).",
            arg_group='Microsoft')
        c.argument('git_hub_client_id',
                   options_list=['--github-client-id'],
                   arg_group='GitHub',
                   help="The Client Id of the GitHub app used for login.")
        c.argument('git_hub_client_secret',
                   options_list=['--github-client-secret'],
                   arg_group='GitHub',
                   help="The Client Secret of the GitHub app used for login.")
        c.argument(
            'git_hub_client_secret_setting_name',
            arg_group='GitHub',
            options_list=[
                '--github-client-secret-setting-name',
                '--github-secret-setting'
            ],
            help=
            "The app setting name that contains the client secret of the Github app used for GitHub Login."
        )
        c.argument(
            'git_hub_o_auth_scopes',
            options_list=['--github-oauth-scopes', '--github-scopes'],
            arg_group='GitHub',
            help=
            "The OAuth 2.0 scopes that will be requested as part of GitHub Login authentication."
        )
예제 #9
0
def load_arguments(self, _):
    from argcomplete.completers import FilesCompleter

    from azure.mgmt.resource.locks.models import LockLevel
    from azure.mgmt.resource.managedapplications.models import ApplicationLockLevel

    from azure.cli.core.api import get_subscription_id_list
    from azure.cli.core.commands.parameters import (
        resource_group_name_type, get_location_type, tag_type, tags_type, get_resource_group_completion_list, no_wait_type, file_type,
        get_enum_type, get_three_state_flag)
    from azure.cli.core.profiles import ResourceType
    from azure.cli.core.local_context import LocalContextAttribute, LocalContextAction, ALL

    from knack.arguments import ignore_type, CLIArgumentType

    from azure.cli.command_modules.resource._completers import (
        get_policy_completion_list, get_policy_set_completion_list, get_policy_assignment_completion_list,
        get_resource_types_completion_list, get_providers_completion_list)
    from azure.cli.command_modules.resource._validators import (
        validate_lock_parameters, validate_resource_lock, validate_group_lock, validate_subscription_lock, validate_metadata, RollbackAction,
        validate_msi)
    from azure.cli.command_modules.resource.parameters import TagUpdateOperation

    DeploymentMode, WhatIfResultFormat, ChangeType = self.get_models('DeploymentMode', 'WhatIfResultFormat', 'ChangeType')

    # BASIC PARAMETER CONFIGURATION

    resource_name_type = CLIArgumentType(options_list=['--name', '-n'], help='The resource name. (Ex: myC)')
    resource_type_type = CLIArgumentType(help="The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC')")
    resource_namespace_type = CLIArgumentType(options_list='--namespace', completer=get_providers_completion_list, help="Provider namespace (Ex: 'Microsoft.Provider')")
    resource_parent_type = CLIArgumentType(required=False, options_list=['--parent'], help="The parent path (Ex: 'resA/myA/resB/myB')")
    existing_policy_definition_name_type = CLIArgumentType(options_list=['--name', '-n'], completer=get_policy_completion_list, help='The policy definition name.')
    existing_policy_set_definition_name_type = CLIArgumentType(options_list=['--name', '-n'], completer=get_policy_set_completion_list, help='The policy set definition name.')
    subscription_type = CLIArgumentType(options_list='--subscription', FilesCompleter=get_subscription_id_list, help='The subscription id of the policy [set] definition.')
    management_group_name_type = CLIArgumentType(options_list='--management-group', help='The name of the management group of the policy [set] definition.')
    identity_scope_type = CLIArgumentType(help="Scope that the system assigned identity can access")
    identity_role_type = CLIArgumentType(options_list=['--role'], help="Role name or id that will be assigned to the managed identity")
    extended_json_format_type = CLIArgumentType(options_list=['--handle-extended-json-format', '-j'], action='store_true',
                                                help='Support to handle extended template content including multiline and comments in deployment')
    deployment_name_type = CLIArgumentType(options_list=['--name', '-n'], required=True, help='The deployment name.')
    deployment_create_name_type = CLIArgumentType(options_list=['--name', '-n'], required=False, help='The deployment name. Default to template file base name')
    management_group_id_type = CLIArgumentType(options_list=['--management-group-id', '-m'], required=True, help='The management group id.')
    deployment_template_file_type = CLIArgumentType(options_list=['--template-file', '-f'], completer=FilesCompleter(), type=file_type,
                                                    help="a template file path in the file system")
    deployment_template_uri_type = CLIArgumentType(options_list=['--template-uri', '-u'], help='a uri to a remote template file')
    deployment_template_spec_type = CLIArgumentType(options_list=['--template-spec', '-s'], is_preview=True, min_api='2019-06-01', help="The template spec resource id.")
    deployment_parameters_type = CLIArgumentType(options_list=['--parameters', '-p'], action='append', nargs='+', completer=FilesCompleter(), help='the deployment parameters')
    filter_type = CLIArgumentType(options_list=['--filter'], is_preview=True,
                                  help='Filter expression using OData notation. You can use --filter "provisioningState eq \'{state}\'" to filter provisioningState. '
                                       'To get more information, please visit https://docs.microsoft.com/en-us/rest/api/resources/deployments/listatsubscriptionscope#uri-parameters')
    no_prompt = CLIArgumentType(arg_type=get_three_state_flag(), help='The option to disable the prompt of missing parameters for ARM template. '
                                'When the value is true, the prompt requiring users to provide missing parameter will be ignored. The default value is false.')

    deployment_what_if_result_format_type = CLIArgumentType(options_list=['--result-format', '-r'],
                                                            arg_type=get_enum_type(WhatIfResultFormat, "FullResourcePayloads"),
                                                            is_preview=True, min_api='2019-07-01')
    deployment_what_if_no_pretty_print_type = CLIArgumentType(options_list=['--no-pretty-print'], action='store_true',
                                                              help='Disable pretty-print for What-If results. When set, the output format type will be used.')
    deployment_what_if_confirmation_type = CLIArgumentType(options_list=['--confirm-with-what-if', '-c'], action='store_true',
                                                           help='Instruct the command to run deployment What-If before executing the deployment. It then prompts you to acknowledge resource changes before it continues.',
                                                           is_preview=True, min_api='2019-07-01')
    deployment_what_if_exclude_change_types_type = CLIArgumentType(nargs="+", options_list=['--exclude-change-types', '-x'],
                                                                   arg_type=get_enum_type(ChangeType),
                                                                   help='Space-separated list of resource change types to be excluded from What-If results.',
                                                                   is_preview=True, min_api='2019-07-01')
    tag_name_type = CLIArgumentType(options_list=['--name', '-n'], help='The tag name.')
    tag_value_type = CLIArgumentType(options_list='--value', help='The tag value.')
    tag_resource_id_type = CLIArgumentType(options_list='--resource-id',
                                           help='The resource identifier for the tagged entity. A resource, a resource group or a subscription may be tagged.',
                                           min_api='2019-10-01')

    latest_include_preview_type = CLIArgumentType(options_list=['--latest-include-preview', '-v'], is_preview=True,
                                                  action='store_true', arg_group='Resource Id',
                                                  help='Indicate that the latest api-version will be used regardless of whether it is preview version (like 2020-01-01-preview) or not. '
                                                       'For example, if the supported api-version of resource provider is 2020-01-01-preview and 2019-01-01: '
                                                       'when passing in this parameter it will take the latest version 2020-01-01-preview, otherwise it will take the latest stable version 2019-01-01 without passing in this parameter')

    ts_display_name_type = CLIArgumentType(options_list=['--display-name', '-d'], help='The display name of the template spec')
    ts_description_type = CLIArgumentType(options_list=['--description'], help='The description of the parent template spec.')
    ts_version_description_type = CLIArgumentType(options_list=['--version-description'], help='The description of the template spec version.')

    _PROVIDER_HELP_TEXT = 'the resource namespace, aka \'provider\''

    with self.argument_context('resource') as c:
        c.argument('no_wait', no_wait_type)
        c.argument('resource_group_name', resource_group_name_type, arg_group='Resource Id')
        c.ignore('resource_id')
        c.argument('resource_name', resource_name_type, arg_group='Resource Id')
        c.argument('api_version', help='The api version of the resource (omit for the latest stable version)', required=False, arg_group='Resource Id')
        c.argument('resource_provider_namespace', resource_namespace_type, arg_group='Resource Id')
        c.argument('resource_type', arg_type=resource_type_type, completer=get_resource_types_completion_list, arg_group='Resource Id')
        c.argument('parent_resource_path', resource_parent_type, arg_group='Resource Id')
        c.argument('tag', tag_type)
        c.argument('tags', tags_type)
        c.argument('resource_ids', nargs='+', options_list=['--ids'], help='One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.', arg_group='Resource Id')
        c.argument('include_response_body', arg_type=get_three_state_flag(), help='Use if the default command output doesn\'t capture all of the property data.')
        c.argument('latest_include_preview', latest_include_preview_type)

    with self.argument_context('resource list') as c:
        c.argument('name', resource_name_type)

    with self.argument_context('resource move') as c:
        c.argument('ids', nargs='+')

    with self.argument_context('resource invoke-action') as c:
        c.argument('action', help='The action that will be invoked on the specified resource')
        c.argument('request_body', help='JSON encoded parameter arguments for the action that will be passed along in the post request body. Use @{file} to load from a file.')

    with self.argument_context('resource create') as c:
        c.argument('resource_id', options_list=['--id'], help='Resource ID.', action=None)
        c.argument('properties', options_list=['--properties', '-p'], help='a JSON-formatted string containing resource properties')
        c.argument('is_full_object', action='store_true', help='Indicate that the properties object includes other options such as location, tags, sku, and/or plan.')

    with self.argument_context('resource link') as c:
        c.argument('target_id', options_list=['--target', c.deprecate(target='--target-id', redirect='--target', hide=True)], help='Fully-qualified resource ID of the resource link target.')
        c.argument('link_id', options_list=['--link', c.deprecate(target='--link-id', redirect='--link', hide=True)], help='Fully-qualified resource ID of the resource link.')
        c.argument('notes', help='Notes for the link.')
        c.argument('scope', help='Fully-qualified scope for retrieving links.')
        c.argument('filter_string', options_list=['--filter', c.deprecate(target='--filter-string', redirect='--filter', hide=True)], help='Filter string for limiting results.')

    with self.argument_context('resource tag') as c:
        c.argument('is_incremental', action='store_true', options_list=['--is-incremental', '-i'],
                   help='The option to add tags incrementally without deleting the original tags. If the key of new tag and original tag are duplicated, the original value will be overwritten.')

    with self.argument_context('resource wait') as c:
        c.ignore('latest_include_preview')

    with self.argument_context('provider') as c:
        c.ignore('top')
        c.argument('resource_provider_namespace', options_list=['--namespace', '-n'], completer=get_providers_completion_list, help=_PROVIDER_HELP_TEXT)

    with self.argument_context('provider register') as c:
        c.argument('wait', action='store_true', help='wait for the registration to finish')

    with self.argument_context('provider unregister') as c:
        c.argument('wait', action='store_true', help='wait for unregistration to finish')

    with self.argument_context('provider operation') as c:
        c.argument('api_version', help="The api version of the 'Microsoft.Authorization/providerOperations' resource (omit for the latest stable version)")

    with self.argument_context('feature') as c:
        c.argument('resource_provider_namespace', options_list='--namespace', required=True, help=_PROVIDER_HELP_TEXT)
        c.argument('feature_name', options_list=['--name', '-n'], help='the feature name')

    with self.argument_context('feature list') as c:
        c.argument('resource_provider_namespace', options_list='--namespace', required=False, help=_PROVIDER_HELP_TEXT)

    with self.argument_context('policy') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type, help='the resource group where the policy will be applied')

    with self.argument_context('policy definition', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('policy_definition_name', arg_type=existing_policy_definition_name_type)
        c.argument('rules', help='JSON formatted string or a path to a file with such content', type=file_type, completer=FilesCompleter())
        c.argument('display_name', help='Display name of policy definition.')
        c.argument('description', help='Description of policy definition.')
        c.argument('params', help='JSON formatted string or a path to a file or uri with parameter definitions.', type=file_type, completer=FilesCompleter(), min_api='2016-12-01')
        c.argument('metadata', min_api='2017-06-01-preview', nargs='+', validator=validate_metadata, help='Metadata in space-separated key=value pairs.')
        c.argument('management_group', arg_type=management_group_name_type)
        c.argument('mode', options_list=['--mode', '-m'], help='Mode of the policy definition, e.g. All, Indexed. Please visit https://aka.ms/azure-policy-mode for more information.', min_api='2016-12-01')
        c.argument('subscription', arg_type=subscription_type)
        c.ignore('_subscription')  # disable global subscription

    with self.argument_context('policy definition create', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('name', options_list=['--name', '-n'], help='Name of the new policy definition.')

    with self.argument_context('policy assignment', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.ignore('_subscription')
        c.argument('name', options_list=['--name', '-n'], completer=get_policy_assignment_completion_list, help='Name of the policy assignment.')
        c.argument('scope', help='Scope to which this policy assignment applies.')
        c.argument('disable_scope_strict_match', action='store_true', help='Include policy assignments either inherited from parent scope or at child scope.')
        c.argument('display_name', help='Display name of the policy assignment.')
        c.argument('policy', help='Name or id of the policy definition.', completer=get_policy_completion_list)

    with self.argument_context('policy assignment create', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('name', options_list=['--name', '-n'], help='Name of the new policy assignment.')
        c.argument('params', options_list=['--params', '-p'], help='JSON formatted string or a path to a file or uri with parameter values of the policy rule.', type=file_type, completer=FilesCompleter(), min_api='2016-12-01')

    with self.argument_context('policy assignment create', resource_type=ResourceType.MGMT_RESOURCE_POLICY, min_api='2017-06-01-preview') as c:
        c.argument('policy_set_definition', options_list=['--policy-set-definition', '-d'], help='Name or id of the policy set definition.')
        c.argument('sku', options_list=['--sku', '-s'], help='policy sku.', arg_type=get_enum_type(['free', 'standard']))
        c.argument('notscopes', options_list='--not-scopes', nargs='+')

    with self.argument_context('policy assignment create', resource_type=ResourceType.MGMT_RESOURCE_POLICY, min_api='2018-05-01') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), help='The location of the policy assignment. Only required when utilizing managed identity.')

    with self.argument_context('policy assignment create', resource_type=ResourceType.MGMT_RESOURCE_POLICY, arg_group='Managed Identity', min_api='2018-05-01') as c:
        c.argument('assign_identity', nargs='*', validator=validate_msi, help="Assigns a system assigned identity to the policy assignment.")
        c.argument('identity_scope', arg_type=identity_scope_type)
        c.argument('identity_role', arg_type=identity_role_type)

    with self.argument_context('policy assignment create', resource_type=ResourceType.MGMT_RESOURCE_POLICY, min_api='2019-06-01') as c:
        c.argument('enforcement_mode', options_list=['--enforcement-mode', '-e'], help='Enforcement mode of the policy assignment, e.g. Default, DoNotEnforce. Please visit https://aka.ms/azure-policyAssignment-enforcement-mode for more information.', arg_type=get_enum_type(['Default', 'DoNotEnforce']))

    with self.argument_context('policy assignment identity', resource_type=ResourceType.MGMT_RESOURCE_POLICY, min_api='2018-05-01') as c:
        c.argument('identity_scope', arg_type=identity_scope_type)
        c.argument('identity_role', arg_type=identity_role_type)

    with self.argument_context('policy set-definition', min_api='2017-06-01-preview', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('policy_set_definition_name', arg_type=existing_policy_set_definition_name_type)
        c.argument('display_name', help='Display name of policy set definition.')
        c.argument('description', help='Description of policy set definition.')
        c.argument('params', help='JSON formatted string or a path to a file or uri with parameter definitions.', type=file_type, completer=FilesCompleter())
        c.argument('definitions', help='JSON formatted string or a path to a file or uri containing definitions.', type=file_type, completer=FilesCompleter())
        c.argument('definition_groups', min_api='2019-09-01', help='JSON formatted string or a path to a file or uri containing policy definition groups. Groups are used to organize policy definitions within a policy set.', type=file_type, completer=FilesCompleter())
        c.argument('metadata', nargs='+', validator=validate_metadata, help='Metadata in space-separated key=value pairs.')
        c.argument('management_group', arg_type=management_group_name_type)
        c.argument('subscription', arg_type=subscription_type)
        c.ignore('_subscription')  # disable global subscription

    with self.argument_context('policy set-definition create', min_api='2017-06-01-preview', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('name', options_list=['--name', '-n'], help='Name of the new policy set definition.')

    with self.argument_context('group') as c:
        c.argument('tag', tag_type)
        c.argument('tags', tags_type)
        c.argument('resource_group_name', resource_group_name_type, options_list=['--name', '-n', '--resource-group', '-g'])

    with self.argument_context('group deployment') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type, completer=get_resource_group_completion_list)
        c.argument('deployment_name', arg_type=deployment_name_type)
        c.argument('template_file', arg_type=deployment_template_file_type)
        c.argument('template_uri', arg_type=deployment_template_uri_type)
        c.argument('mode', arg_type=get_enum_type(DeploymentMode, default='incremental'),
                   help='Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)')
        c.argument('parameters', arg_type=deployment_parameters_type)
        c.argument('rollback_on_error', nargs='?', action=RollbackAction,
                   help='The name of a deployment to roll back to on error, or use as a flag to roll back to the last successful deployment.')

    with self.argument_context('group deployment create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('aux_subscriptions', nargs='+', options_list=['--aux-subs'],
                   help='Auxiliary subscriptions which will be used during deployment across tenants.',
                   deprecate_info=c.deprecate(target='--aux-subs', redirect='--aux-tenants'))
        c.argument('aux_tenants', nargs='+', options_list=['--aux-tenants'],
                   help='Auxiliary tenants which will be used during deployment across tenants.')
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('group deployment validate') as c:
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('group deployment list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('group deployment operation show') as c:
        c.argument('operation_ids', nargs='+', help='A list of operation ids to show')

    with self.argument_context('deployment') as c:
        c.argument('deployment_name', arg_type=deployment_name_type)
        c.argument('deployment_location', arg_type=get_location_type(self.cli_ctx), required=True)
        c.argument('template_file', arg_type=deployment_template_file_type)
        c.argument('template_uri', arg_type=deployment_template_uri_type)
        c.argument('template_spec', arg_type=deployment_template_spec_type)
        c.argument('parameters', arg_type=deployment_parameters_type)

    with self.argument_context('deployment create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('confirm_with_what_if', arg_type=deployment_what_if_confirmation_type)
        c.argument('what_if_result_format', options_list=['--what-if-result-format', '-r'],
                   arg_type=deployment_what_if_result_format_type)
        c.argument('what_if_exclude_change_types', options_list=['--what-if-exclude-change-types', '-x'],
                   arg_type=deployment_what_if_exclude_change_types_type,
                   help="Space-separated list of resource change types to be excluded from What-If results. Applicable when --confirm-with-what-if is set.")

    with self.argument_context('deployment validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('deployment operation') as c:
        c.argument('operation_ids', nargs='+', help='A list of operation ids to show')

    with self.argument_context('deployment list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment sub') as c:
        c.argument('deployment_location', arg_type=get_location_type(self.cli_ctx), required=True)

    with self.argument_context('deployment sub create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('confirm_with_what_if', arg_type=deployment_what_if_confirmation_type)
        c.argument('what_if_result_format', options_list=['--what-if-result-format', '-r'],
                   arg_type=deployment_what_if_result_format_type)
        c.argument('what_if_exclude_change_types', options_list=['--what-if-exclude-change-types', '-x'],
                   arg_type=deployment_what_if_exclude_change_types_type,
                   help="Space-separated list of resource change types to be excluded from What-If results. Applicable when --confirm-with-what-if is set.")

    with self.argument_context('deployment sub what-if') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('result_format', arg_type=deployment_what_if_result_format_type)
        c.argument('no_pretty_print', arg_type=deployment_what_if_no_pretty_print_type)
        c.argument('exclude_change_types', arg_type=deployment_what_if_exclude_change_types_type)

    with self.argument_context('deployment sub validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('deployment sub list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment group') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type, completer=get_resource_group_completion_list, required=True)
        c.argument('mode', arg_type=get_enum_type(DeploymentMode, default='incremental'), help='Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)')
        c.argument('rollback_on_error', nargs='?', action=RollbackAction,
                   help='The name of a deployment to roll back to on error, or use as a flag to roll back to the last successful deployment.')

    with self.argument_context('deployment group create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('aux_subscriptions', nargs='+', options_list=['--aux-subs'],
                   help='Auxiliary subscriptions which will be used during deployment across tenants.',
                   deprecate_info=c.deprecate(target='--aux-subs', redirect='--aux-tenants'))
        c.argument('aux_tenants', nargs='+', options_list=['--aux-tenants'],
                   help='Auxiliary tenants which will be used during deployment across tenants.')
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('confirm_with_what_if', arg_type=deployment_what_if_confirmation_type)
        c.argument('what_if_result_format', options_list=['--what-if-result-format', '-r'],
                   arg_type=deployment_what_if_result_format_type)
        c.argument('what_if_exclude_change_types', options_list=['--what-if-exclude-change-types', '-x'],
                   arg_type=deployment_what_if_exclude_change_types_type,
                   help="Space-separated list of resource change types to be excluded from What-If results. Applicable when --confirm-with-what-if is set.")

    with self.argument_context('deployment group what-if') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('aux_tenants', nargs='+', options_list=['--aux-tenants'],
                   help='Auxiliary tenants which will be used during deployment across tenants.')
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('result_format', arg_type=deployment_what_if_result_format_type)
        c.argument('no_pretty_print', arg_type=deployment_what_if_no_pretty_print_type)
        c.argument('exclude_change_types', arg_type=deployment_what_if_exclude_change_types_type)
        c.ignore("rollback_on_error")

    with self.argument_context('deployment group validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('deployment group list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment mg') as c:
        c.argument('management_group_id', arg_type=management_group_id_type)
        c.argument('deployment_location', arg_type=get_location_type(self.cli_ctx), required=True)

    with self.argument_context('deployment mg create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('confirm_with_what_if', arg_type=deployment_what_if_confirmation_type, min_api="2019-10-01")
        c.argument('what_if_result_format', options_list=['--what-if-result-format', '-r'],
                   arg_type=deployment_what_if_result_format_type, min_api="2019-10-01")
        c.argument('what_if_exclude_change_types', options_list=['--what-if-exclude-change-types', '-x'],
                   arg_type=deployment_what_if_exclude_change_types_type,
                   help="Space-separated list of resource change types to be excluded from What-If results. Applicable when --confirm-with-what-if is set.",
                   min_api="2019-10-01")

    with self.argument_context('deployment mg what-if') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('result_format', arg_type=deployment_what_if_result_format_type)
        c.argument('no_pretty_print', arg_type=deployment_what_if_no_pretty_print_type)
        c.argument('exclude_change_types', arg_type=deployment_what_if_exclude_change_types_type)

    with self.argument_context('deployment mg validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('deployment mg list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment operation mg') as c:
        c.argument('management_group_id', arg_type=management_group_id_type)

    with self.argument_context('deployment tenant') as c:
        c.argument('deployment_location', arg_type=get_location_type(self.cli_ctx), required=True)

    with self.argument_context('deployment tenant create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('confirm_with_what_if', arg_type=deployment_what_if_confirmation_type, min_api="2019-10-01")
        c.argument('what_if_result_format', options_list=['--what-if-result-format', '-r'],
                   arg_type=deployment_what_if_result_format_type, min_api="2019-10-01")
        c.argument('what_if_exclude_change_types', options_list=['--what-if-exclude-change-types', '-x'],
                   arg_type=deployment_what_if_exclude_change_types_type,
                   help="Space-separated list of resource change types to be excluded from What-If results. Applicable when --confirm-with-what-if is set.",
                   min_api="2019-10-01")

    with self.argument_context('deployment tenant what-if') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('no_prompt', arg_type=no_prompt)
        c.argument('result_format', arg_type=deployment_what_if_result_format_type)
        c.argument('no_pretty_print', arg_type=deployment_what_if_no_pretty_print_type)
        c.argument('exclude_change_types', arg_type=deployment_what_if_exclude_change_types_type)

    with self.argument_context('deployment tenant validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))
        c.argument('no_prompt', arg_type=no_prompt)

    with self.argument_context('deployment tenant list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('group export') as c:
        c.argument('include_comments', action='store_true')
        c.argument('include_parameter_default_value', action='store_true')
        c.argument('skip_resource_name_params', action='store_true')
        c.argument('skip_all_params', action='store_true')
        c.argument('resource_ids', nargs='+', options_list='--resource-ids')

    with self.argument_context('group create') as c:
        c.argument('rg_name', options_list=['--name', '--resource-group', '-n', '-g'],
                   help='name of the new resource group', completer=None,
                   local_context_attribute=LocalContextAttribute(
                       name='resource_group_name', actions=[LocalContextAction.SET], scopes=[ALL]))
        c.argument('managed_by', min_api='2016-09-01', help='The ID of the resource that manages this resource group.')

    with self.argument_context('group delete') as c:
        c.argument('resource_group_name', resource_group_name_type,
                   options_list=['--name', '-n', '--resource-group', '-g'], local_context_attribute=None)

    with self.argument_context('tag') as c:
        c.argument('tag_name', tag_name_type)
        c.argument('tag_value', tag_value_type)
        c.argument('resource_id', tag_resource_id_type)
        c.argument('tags', tags_type)
        c.argument('operation', arg_type=get_enum_type([item.value for item in list(TagUpdateOperation)]),
                   help='The update operation: options include Merge, Replace and Delete.')

    with self.argument_context('lock') as c:
        c.argument('lock_name', options_list=['--name', '-n'], validator=validate_lock_parameters)
        c.argument('level', arg_type=get_enum_type(LockLevel), options_list=['--lock-type', '-t'], help='The type of lock restriction.')
        c.argument('parent_resource_path', resource_parent_type)
        c.argument('resource_provider_namespace', resource_namespace_type)
        c.argument('resource_type', arg_type=resource_type_type, completer=get_resource_types_completion_list)
        c.argument('resource_name', options_list=['--resource', '--resource-name'], help='Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.')
        c.argument('ids', nargs='+', options_list='--ids', help='One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.')
        c.argument('resource_group', resource_group_name_type, validator=validate_lock_parameters)

    with self.argument_context('resource lock') as c:
        c.argument('resource_group', resource_group_name_type)
        c.argument('resource_name', options_list=['--resource', '--resource-name'], help='If an ID is given, other resource arguments should not be given.', validator=validate_resource_lock)

    with self.argument_context('group lock') as c:
        c.argument('resource_group', resource_group_name_type, validator=validate_group_lock, id_part=None)

    with self.argument_context('group lock create') as c:
        c.argument('resource_group', required=True)

    with self.argument_context('account lock') as c:
        c.argument('resource_group', ignore_type, validator=validate_subscription_lock)

    for scope in ['account', 'group']:
        with self.argument_context('{} lock'.format(scope)) as c:
            c.ignore('resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name')

    for scope in ['lock', 'account lock', 'group lock', 'resource lock']:
        with self.argument_context(scope) as c:
            c.argument('lock_name', options_list=['--name', '-n'], help='Name of the lock')
            c.argument('level', options_list=['--lock-type', '-t'], arg_type=get_enum_type([LockLevel.can_not_delete, LockLevel.read_only]), help='The type of lock restriction.')
            c.argument('ids', nargs='+', options_list='--ids', help='One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.')
            c.argument('notes', help='Notes about this lock.')

    with self.argument_context('managedapp') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type, help='the resource group of the managed application', id_part='resource_group')
        c.argument('application_name', options_list=['--name', '-n'], id_part='name')
        c.argument('tags', tags_type)

    with self.argument_context('managedapp definition') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type, help='the resource group of the managed application definition', id_part='resource_group')
        c.argument('application_definition_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('managedapp create') as c:
        c.argument('name', options_list=['--name', '-n'], help='name of the new managed application', completer=None)
        c.argument('location', help='the managed application location')
        c.argument('managedapp_definition_id', options_list=['--managedapp-definition-id', '-d'], help='the full qualified managed application definition id')
        c.argument('managedby_resource_group_id', options_list=['--managed-rg-id', '-m'], help='the resource group managed by the managed application')
        c.argument('parameters', help='JSON formatted string or a path to a file with such content', type=file_type)

    with self.argument_context('managedapp definition create') as c:
        c.argument('lock_level', arg_type=get_enum_type(ApplicationLockLevel), help='The type of lock restriction.')
        c.argument('authorizations', options_list=['--authorizations', '-a'], nargs='+', help="space-separated authorization pairs in a format of `<principalId>:<roleDefinitionId>`")
        c.argument('createUiDefinition', options_list=['--create-ui-definition', '-c'], help='JSON formatted string or a path to a file with such content', type=file_type)
        c.argument('mainTemplate', options_list=['--main-template', '-t'], help='JSON formatted string or a path to a file with such content', type=file_type)

    with self.argument_context('account') as c:
        c.argument('subscription', options_list=['--subscription', '-s'], help='Name or ID of subscription.', completer=get_subscription_id_list)
        c.ignore('_subscription')  # hide global subscription parameter

    with self.argument_context('account management-group') as c:
        c.argument('group_name', options_list=['--name', '-n'])

    with self.argument_context('account management-group show') as c:
        c.argument('expand', options_list=['--expand', '-e'], action='store_true')
        c.argument('recurse', options_list=['--recurse', '-r'], action='store_true')

    with self.argument_context('account management-group create') as c:
        c.argument('display_name', options_list=['--display-name', '-d'])
        c.argument('parent', options_list=['--parent', '-p'])

    with self.argument_context('account management-group update') as c:
        c.argument('display_name', options_list=['--display-name', '-d'])
        c.argument('parent_id', options_list=['--parent', '-p'])

    with self.argument_context('ts') as c:
        c.argument('name', options_list=['--name', '-n'], help='The name of the template spec.')
        c.argument('version', options_list=['--version', '-v'], help='The template spec version.')

    with self.argument_context('ts create') as c:
        c.argument('resource_group', arg_type=resource_group_name_type, help='The resource group to store the template spec.')
        c.argument('template_file', arg_type=deployment_template_file_type)
        c.argument('location', options_list=['--location', '-l'], help='The location to store the template-spec and template-spec version(s). Cannot be changed after creation.')
        c.argument('display_name', arg_type=ts_display_name_type)
        c.argument('description', arg_type=ts_description_type)
        c.argument('version_description', arg_type=ts_version_description_type)

    with self.argument_context('ts update') as c:
        c.argument('resource_group', arg_type=resource_group_name_type, help='The resource group to store the template spec.')
        c.argument('template_spec', arg_type=deployment_template_spec_type)
        c.argument('template_file', arg_type=deployment_template_file_type)
        c.argument('display_name', arg_type=ts_display_name_type)
        c.argument('description', arg_type=ts_description_type)
        c.argument('version_description', arg_type=ts_version_description_type)

    with self.argument_context('ts show') as c:
        c.argument('template_spec', arg_type=deployment_template_spec_type)

    with self.argument_context('ts export') as c:
        c.argument('output_folder', options_list=['--output-folder'], help='Existing folder to output export(s).')
        c.argument('template_spec', arg_type=deployment_template_spec_type)

    with self.argument_context('ts delete') as c:
        c.argument('resource_group', arg_type=resource_group_name_type, help='The resource group where the template spec or template spec version is stored.')
        c.argument('template_spec', arg_type=deployment_template_spec_type)

    with self.argument_context('ts list') as c:
        c.argument('resource_group', arg_type=resource_group_name_type)
예제 #10
0
from azext_iot._validators import mode2_iot_login_handler
from azext_iot.assets.user_messages import info_param_properties_device
from azure.cli.core.local_context import LocalContextAttribute, LocalContextAction

auth_type_dataplane_param_type = CLIArgumentType(
    options_list=["--auth-type"],
    arg_type=get_enum_type(AuthenticationTypeDataplane,
                           AuthenticationTypeDataplane.key.value),
    arg_group="Access Control",
    help=
    "Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. "
    "You can configure the default using `az configure --defaults iothub-data-auth-type=<auth-type-value>`",
    configured_default="iothub-data-auth-type",
    local_context_attribute=LocalContextAttribute(
        name="iothub-data-auth-type",
        actions=[LocalContextAction.SET, LocalContextAction.GET],
        scopes=["iot"],
    ),
)

hub_name_type = CLIArgumentType(
    completer=get_resource_name_completion_list("Microsoft.Devices/IotHubs"),
    help="IoT Hub name.",
)

event_msg_prop_type = CLIArgumentType(
    options_list=["--properties", "--props", "-p"],
    nargs="*",
    choices=CaseInsensitiveList(["sys", "app", "anno", "all"]),
    help="Indicate key message properties to output. "
    "sys = system properties, app = application properties, anno = annotations",
예제 #11
0
def load_arguments(self, _):  # pylint: disable=too-many-locals, too-many-statements
    for scope in ('mysql', 'postgres', 'sql'):
        with self.argument_context('{} up'.format(scope)) as c:
            c.argument('location', arg_type=get_location_type(self.cli_ctx))
            c.argument('server_name',
                       options_list=['--server-name', '-s'],
                       help='Name of the server.')
            c.argument('administrator_login',
                       options_list=['--admin-user', '-u'],
                       arg_group='Authentication',
                       help='The login username of the administrator.')
            c.argument(
                'administrator_login_password',
                options_list=['--admin-password', '-p'],
                arg_group='Authentication',
                help=
                'The login password of the administrator. Minimum 8 characters and maximum 128 characters. '
                'Password must contain characters from three of the following categories: English uppercase '
                'letters, English lowercase letters, numbers, and non-alphanumeric characters.'
                'Your password cannot contain all or part of the login name. Part of a login name is defined '
                'as three or more consecutive alphanumeric characters.')
            c.extra('generate_password',
                    help='Generate a password.',
                    arg_group='Authentication')
            c.argument('database_name',
                       options_list=['--database-name', '-d'],
                       help='The name of a database to initialize.')
            c.argument('tags', tags_type)

        if scope != 'sql':  # SQL alreaady has a core command for displaying connection strings
            with self.argument_context(
                    '{} show-connection-string'.format(scope)) as c:
                c.argument('server_name',
                           options_list=['--server-name', '-s'],
                           help='Name of the server.')
                c.argument('database_name',
                           options_list=['--database-name', '-d'],
                           help='The name of a database.')
                c.argument('administrator_login',
                           options_list=['--admin-user', '-u'],
                           help='The login username of the administrator.')
                c.argument('administrator_login_password',
                           options_list=['--admin-password', '-p'],
                           help='The login password of the administrator.')

        with self.argument_context('{} down'.format(scope)) as c:
            c.argument('server_name',
                       options_list=['--server-name', '-s'],
                       help='Name of the server.')
            c.argument('delete_group',
                       action='store_true',
                       help="Delete the resource group.")

    for scope in ('mysql', 'postgres'):
        with self.argument_context('{} up'.format(scope)) as c:
            c.argument(
                'sku_name',
                options_list=['--sku-name'],
                default='GP_Gen5_2',
                help=
                'The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.'
            )
            c.argument('backup_retention',
                       type=int,
                       help='The number of days a backup is retained.')
            c.argument('geo_redundant_backup',
                       arg_type=get_enum_type(GeoRedundantBackup),
                       default=GeoRedundantBackup.disabled.value,
                       help='Enable Geo-redundant or not for server backup.')
            c.argument(
                'storage_mb',
                options_list=['--storage-size'],
                type=int,
                help='The max storage size of the server. Unit is megabytes.')
            c.argument(
                'ssl_enforcement',
                arg_type=get_enum_type(SslEnforcementEnum),
                default=SslEnforcementEnum.enabled.value,
                help='Enable ssl enforcement or not when connect to server.')

    with self.argument_context('mysql up') as c:
        c.argument('version', help='Server version', default='5.7')

    with self.argument_context('postgres up') as c:
        c.argument('server_name',
                   options_list=['--server-name', '-s'],
                   help='Name of the server.',
                   local_context_attribute=LocalContextAttribute(
                       name='postgres_server_name',
                       actions=[LocalContextAction.SET],
                       scopes=['cupertino']))
        c.argument('administrator_login',
                   options_list=['--admin-user', '-u'],
                   arg_group='Authentication',
                   help='The login username of the administrator.',
                   local_context_attribute=LocalContextAttribute(
                       name='postgres_admin_user_name',
                       actions=[LocalContextAction.SET],
                       scopes=['cupertino']))
        c.argument('database_name',
                   options_list=['--database-name', '-d'],
                   help='The name of a database to initialize.',
                   local_context_attribute=LocalContextAttribute(
                       name='postgres_database_name',
                       actions=[LocalContextAction.SET],
                       scopes=['cupertino']))
        c.argument('version', help='Server version', default='10')

    with self.argument_context('sql up') as c:
        c.argument('version', help='Server version', default='12.0')
def load_arguments(self, _):  # pylint: disable=too-many-locals, too-many-statements
    from argcomplete.completers import FilesCompleter
    from knack.arguments import CLIArgumentType
    from azure.cli.core.commands.parameters import get_resource_name_completion_list

    from .sdkutil import get_table_data_type
    from .completers import get_storage_name_completion_list, get_container_name_completions

    t_base_blob_service = self.get_sdk('blob.baseblobservice#BaseBlobService')
    t_file_service = self.get_sdk('file#FileService')
    t_table_service = get_table_data_type(self.cli_ctx, 'table', 'TableService')

    acct_name_type = CLIArgumentType(options_list=['--account-name', '-n'], help='The storage account name.',
                                     id_part='name',
                                     completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'),
                                     local_context_attribute=LocalContextAttribute(
                                         name='storage_account_name', actions=[LocalContextAction.GET]))
    blob_name_type = CLIArgumentType(options_list=['--blob-name', '-b'], help='The blob name.',
                                     completer=get_storage_name_completion_list(t_base_blob_service, 'list_blobs',
                                                                                parent='container_name'))
    container_name_type = CLIArgumentType(options_list=['--container-name', '-c'], help='The container name.',
                                          completer=get_container_name_completions)
    directory_path_type = CLIArgumentType(options_list=['--directory-path', '-d'], help='The directory path name.',
                                          parent='container_name')
    share_name_type = CLIArgumentType(options_list=['--share-name', '-s'], help='The file share name.',
                                      completer=get_storage_name_completion_list(t_file_service, 'list_shares'))
    table_name_type = CLIArgumentType(options_list=['--table-name', '-t'],
                                      completer=get_storage_name_completion_list(t_table_service, 'list_tables'))
    large_file_share_type = CLIArgumentType(
        action='store_true', min_api='2019-04-01',
        help='Enable the capability to support large file shares with more than 5 TiB capacity for storage account.'
             'Once the property is enabled, the feature cannot be disabled. Currently only supported for LRS and '
             'ZRS replication types, hence account conversions to geo-redundant accounts would not be possible. '
             'For more information, please refer to https://go.microsoft.com/fwlink/?linkid=2086047.')
    adds_type = CLIArgumentType(arg_type=get_three_state_flag(), min_api='2019-04-01',
                                arg_group='Azure Files Identity Based Authentication',
                                help='Enable Azure Files Active Directory Domain Service Authentication for '
                                     'storage account. When --enable-files-adds is set to true, Azure Active '
                                     'Directory Properties arguments must be provided.')
    aadds_type = CLIArgumentType(arg_type=get_three_state_flag(), min_api='2018-11-01',
                                 arg_group='Azure Files Identity Based Authentication',
                                 help='Enable Azure Active Directory Domain Services authentication for Azure Files')
    domain_name_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
                                       help="Specify the primary domain that the AD DNS server is authoritative for. "
                                            "Required when --enable-files-adds is set to True")
    net_bios_domain_name_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
                                                help="Specify the NetBIOS domain name. "
                                                     "Required when --enable-files-adds is set to True")
    forest_name_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
                                       help="Specify the Active Directory forest to get. "
                                            "Required when --enable-files-adds is set to True")
    domain_guid_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
                                       help="Specify the domain GUID. Required when --enable-files-adds is set to True")
    domain_sid_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
                                      help="Specify the security identifier (SID). Required when --enable-files-adds "
                                           "is set to True")
    azure_storage_sid_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
                                             help="Specify the security identifier (SID) for Azure Storage. "
                                                  "Required when --enable-files-adds is set to True")
    sam_account_name_type = CLIArgumentType(min_api='2021-08-01', arg_group="Azure Active Directory Properties",
                                            help="Specify the Active Directory SAMAccountName for Azure Storage.",
                                            is_preview=True)
    t_account_type = self.get_models('ActiveDirectoryPropertiesAccountType', resource_type=CUSTOM_MGMT_STORAGE)
    account_type_type = CLIArgumentType(min_api='2021-08-01', arg_group="Azure Active Directory Properties",
                                        arg_type=get_enum_type(t_account_type), is_preview=True,
                                        help="Specify the Active Directory account type for Azure Storage.")
    t_routing_choice = self.get_models('RoutingChoice', resource_type=CUSTOM_MGMT_STORAGE)
    routing_choice_type = CLIArgumentType(
        arg_group='Routing Preference', arg_type=get_enum_type(t_routing_choice),
        help='Routing Choice defines the kind of network routing opted by the user.',
        min_api='2019-06-01')
    publish_microsoft_endpoints_type = CLIArgumentType(
        arg_group='Routing Preference', arg_type=get_three_state_flag(), min_api='2019-06-01',
        help='A boolean flag which indicates whether microsoft routing storage endpoints are to be published.')
    publish_internet_endpoints_type = CLIArgumentType(
        arg_group='Routing Preference', arg_type=get_three_state_flag(), min_api='2019-06-01',
        help='A boolean flag which indicates whether internet routing storage endpoints are to be published.')
    allow_shared_key_access_type = CLIArgumentType(
        arg_type=get_three_state_flag(), options_list=['--allow-shared-key-access', '-k'], min_api='2019-04-01',
        help='Indicate whether the storage account permits requests to be authorized with the account access key via '
             'Shared Key. If false, then all requests, including shared access signatures, must be authorized with '
             'Azure Active Directory (Azure AD). The default value is null, which is equivalent to true.')
    sas_expiration_period_type = CLIArgumentType(
        options_list=['--sas-expiration-period', '--sas-exp'], min_api='2021-02-01',
        help='Expiration period of the SAS Policy assigned to the storage account, DD.HH:MM:SS.'
    )
    key_expiration_period_in_days_type = CLIArgumentType(
        options_list=['--key-expiration-period-in-days', '--key-exp-days'], min_api='2021-02-01', type=int,
        help='Expiration period in days of the Key Policy assigned to the storage account'
    )
    allow_cross_tenant_replication_type = CLIArgumentType(
        arg_type=get_three_state_flag(), options_list=['--allow-cross-tenant-replication', '-r'], min_api='2021-04-01',
        help='Allow or disallow cross AAD tenant object replication. The default interpretation is true for this '
        'property.')
    t_share_permission = self.get_models('DefaultSharePermission', resource_type=CUSTOM_MGMT_STORAGE)
    default_share_permission_type = CLIArgumentType(
        options_list=['--default-share-permission', '-d'],
        arg_type=get_enum_type(t_share_permission),
        min_api='2020-08-01-preview',
        arg_group='Azure Files Identity Based Authentication',
        help='Default share permission for users using Kerberos authentication if RBAC role is not assigned.')
    action_type = CLIArgumentType(
        help='The action of virtual network rule. Possible value is Allow.'
    )
    immutability_period_since_creation_in_days_type = CLIArgumentType(
        options_list=['--immutability-period-in-days', '--immutability-period'], min_api='2021-06-01',
        help='The immutability period for the blobs in the container since the policy creation, in days.'
    )
    account_immutability_policy_state_enum = self.get_sdk(
        'models._storage_management_client_enums#AccountImmutabilityPolicyState',
        resource_type=CUSTOM_MGMT_STORAGE)
    immutability_policy_state_type = CLIArgumentType(
        arg_type=get_enum_type(account_immutability_policy_state_enum),
        options_list='--immutability-state', min_api='2021-06-01',
        help='Defines the mode of the policy. Disabled state disables the policy, '
        'Unlocked state allows increase and decrease of immutability retention time '
        'and also allows toggling allow-protected-append-write property, '
        'Locked state only allows the increase of the immutability retention time. '
        'A policy can only be created in a Disabled or Unlocked state and can be toggled between the '
        'two states. Only a policy in an Unlocked state can transition to a Locked state which cannot '
        'be reverted.')
    public_network_access_enum = self.get_sdk('models._storage_management_client_enums#PublicNetworkAccess',
                                              resource_type=CUSTOM_MGMT_STORAGE)
    num_results_type = CLIArgumentType(
        default=5000, help='Specifies the maximum number of results to return. Provide "*" to return all.',
        validator=validate_storage_data_plane_list)
    acl_type = CLIArgumentType(options_list=['--acl-spec', '-a'],
                               help='The ACL specification to set on the path in the format '
                                    '"[default:]user|group|other|mask:[entity id or UPN]:r|-w|-x|-,'
                                    '[default:]user|group|other|mask:[entity id or UPN]:r|-w|-x|-,...". '
                                    'e.g."user::rwx,user:john.doe@contoso:rwx,group::r--,other::---,mask::rwx".')
    progress_type = CLIArgumentType(help='Include this flag to disable progress reporting for the command.',
                                    action='store_true', validator=add_upload_progress_callback)
    timeout_type = CLIArgumentType(
        help='Request timeout in seconds. Applies to each call to the service.', type=int
    )

    with self.argument_context('storage') as c:
        c.argument('container_name', container_name_type)
        c.argument('share_name', share_name_type)
        c.argument('table_name', table_name_type)
        c.argument('retry_wait', options_list=('--retry-interval',))
        c.ignore('progress_callback')
        c.argument('metadata', nargs='+',
                   help='Metadata in space-separated key=value pairs. This overwrites any existing metadata.',
                   validator=validate_metadata)
        c.argument('timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

    with self.argument_context('storage', arg_group='Precondition') as c:
        c.argument('if_modified_since', help='Alter only if modified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')',
                   type=get_datetime_type(False))
        c.argument('if_unmodified_since',
                   help='Alter only if unmodified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')',
                   type=get_datetime_type(False))
        c.argument('if_match')
        c.argument('if_none_match')

    with self.argument_context('storage account create', resource_type=CUSTOM_MGMT_STORAGE) as c:
        t_account_type, t_sku_name, t_kind, t_tls_version = \
            self.get_models('AccountType', 'SkuName', 'Kind', 'MinimumTlsVersion',
                            resource_type=CUSTOM_MGMT_STORAGE)
        t_identity_type = self.get_models('IdentityType', resource_type=CUSTOM_MGMT_STORAGE)
        c.register_common_storage_account_options()
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('account_type', help='The storage account type', arg_type=get_enum_type(t_account_type))
        c.argument('account_name', acct_name_type, options_list=['--name', '-n'], completer=None,
                   local_context_attribute=LocalContextAttribute(
                       name='storage_account_name', actions=[LocalContextAction.SET], scopes=[ALL]))
        c.argument('kind', help='Indicate the type of storage account.',
                   arg_type=get_enum_type(t_kind),
                   default='StorageV2' if self.cli_ctx.cloud.profile == 'latest' else 'Storage')
        c.argument('https_only', arg_type=get_three_state_flag(), min_api='2019-04-01',
                   help='Allow https traffic only to storage service if set to true. The default value is true.')
        c.argument('https_only', arg_type=get_three_state_flag(), max_api='2018-11-01',
                   help='Allow https traffic only to storage service if set to true. The default value is false.')
        c.argument('tags', tags_type)
        c.argument('custom_domain', help='User domain assigned to the storage account. Name is the CNAME source.')
        c.argument('sku', help='The storage account SKU.', arg_type=get_enum_type(t_sku_name, default='standard_ragrs'))
        c.argument('enable_sftp', arg_type=get_three_state_flag(), min_api='2021-08-01',
                   is_preview=True, help='Enable Secure File Transfer Protocol.')
        c.argument('enable_local_user', arg_type=get_three_state_flag(), min_api='2021-08-01',
                   is_preview=True, help='Enable local user features.')
        c.argument('enable_files_aadds', aadds_type)
        c.argument('enable_files_adds', adds_type)
        c.argument('enable_large_file_share', arg_type=large_file_share_type)
        c.argument('domain_name', domain_name_type)
        c.argument('net_bios_domain_name', net_bios_domain_name_type)
        c.argument('forest_name', forest_name_type)
        c.argument('domain_guid', domain_guid_type)
        c.argument('domain_sid', domain_sid_type)
        c.argument('azure_storage_sid', azure_storage_sid_type)
        c.argument('sam_account_name', sam_account_name_type)
        c.argument('account_type', account_type_type)
        c.argument('enable_hierarchical_namespace', arg_type=get_three_state_flag(),
                   options_list=['--enable-hierarchical-namespace', '--hns',
                                 c.deprecate(target='--hierarchical-namespace', redirect='--hns', hide=True)],
                   help=" Allow the blob service to exhibit filesystem semantics. This property can be enabled only "
                   "when storage account kind is StorageV2.",
                   min_api='2018-02-01')
        c.argument('encryption_key_type_for_table', arg_type=get_enum_type(['Account', 'Service']),
                   help='Set the encryption key type for Table service. "Account": Table will be encrypted '
                        'with account-scoped encryption key. "Service": Table will always be encrypted with '
                        'service-scoped keys. Currently the default encryption key type is "Service".',
                   min_api='2019-06-01', options_list=['--encryption-key-type-for-table', '-t'])
        c.argument('encryption_key_type_for_queue', arg_type=get_enum_type(['Account', 'Service']),
                   help='Set the encryption key type for Queue service. "Account": Queue will be encrypted '
                        'with account-scoped encryption key. "Service": Queue will always be encrypted with '
                        'service-scoped keys. Currently the default encryption key type is "Service".',
                   min_api='2019-06-01', options_list=['--encryption-key-type-for-queue', '-q'])
        c.argument('routing_choice', routing_choice_type)
        c.argument('publish_microsoft_endpoints', publish_microsoft_endpoints_type)
        c.argument('publish_internet_endpoints', publish_internet_endpoints_type)
        c.argument('require_infrastructure_encryption', options_list=['--require-infrastructure-encryption', '-i'],
                   arg_type=get_three_state_flag(),
                   help='A boolean indicating whether or not the service applies a secondary layer of encryption with '
                   'platform managed keys for data at rest.')
        c.argument('allow_blob_public_access', arg_type=get_three_state_flag(), min_api='2019-04-01',
                   help='Allow or disallow public access to all blobs or containers in the storage account. '
                   'The default value for this property is null, which is equivalent to true. When true, containers '
                   'in the account may be configured for public access. Note that setting this property to true does '
                   'not enable anonymous access to any data in the account. The additional step of configuring the '
                   'public access setting for a container is required to enable anonymous access.')
        c.argument('min_tls_version', arg_type=get_enum_type(t_tls_version),
                   help='The minimum TLS version to be permitted on requests to storage. '
                        'The default interpretation is TLS 1.0 for this property')
        c.argument('allow_shared_key_access', allow_shared_key_access_type)
        c.argument('edge_zone', edge_zone_type, min_api='2020-08-01-preview')
        c.argument('identity_type', arg_type=get_enum_type(t_identity_type), arg_group='Identity',
                   help='The identity type.')
        c.argument('user_identity_id', arg_group='Identity',
                   help='The key is the ARM resource identifier of the identity. Only 1 User Assigned identity is '
                   'permitted here.')
        c.argument('key_expiration_period_in_days', key_expiration_period_in_days_type, is_preview=True)
        c.argument('sas_expiration_period', sas_expiration_period_type, is_preview=True)
        c.argument('allow_cross_tenant_replication', allow_cross_tenant_replication_type)
        c.argument('default_share_permission', default_share_permission_type)
        c.argument('enable_nfs_v3', arg_type=get_three_state_flag(), is_preview=True, min_api='2021-01-01',
                   help='NFS 3.0 protocol support enabled if sets to true.')
        c.argument('enable_alw', arg_type=get_three_state_flag(), min_api='2021-06-01',
                   help='The account level immutability property. The property is immutable and can only be set to true'
                        ' at the account creation time. When set to true, it enables object level immutability for all '
                        'the containers in the account by default.',
                   arg_group='Account Level Immutability',
                   validator=validate_immutability_arguments)
        c.argument('immutability_period_since_creation_in_days',
                   arg_type=immutability_period_since_creation_in_days_type,
                   arg_group='Account Level Immutability',
                   validator=validate_immutability_arguments)
        c.argument('immutability_policy_state', arg_type=immutability_policy_state_type,
                   arg_group='Account Level Immutability',
                   validator=validate_immutability_arguments)
        c.argument('allow_protected_append_writes', arg_type=get_three_state_flag(),
                   options_list=['--allow-protected-append-writes', '--allow-append', '-w'],
                   min_api='2021-06-01',
                   help='This property can only be changed for disabled and unlocked time-based retention policies. '
                        'When enabled, new blocks can be written to an append blob while maintaining immutability '
                        'protection and compliance. Only new blocks can be added and any existing blocks cannot be '
                        'modified or deleted.',
                   arg_group='Account Level Immutability',
                   validator=validate_immutability_arguments)
        c.argument('public_network_access', arg_type=get_enum_type(public_network_access_enum), min_api='2021-06-01',
                   help='Enable or disable public network access to the storage account. '
                        'Possible values include: `Enabled` or `Disabled`.')

    with self.argument_context('storage account update', resource_type=CUSTOM_MGMT_STORAGE) as c:
        t_tls_version = self.get_models('MinimumTlsVersion', resource_type=CUSTOM_MGMT_STORAGE)
        t_identity_type = self.get_models('IdentityType', resource_type=CUSTOM_MGMT_STORAGE)
        c.register_common_storage_account_options()
        c.argument('sku', arg_type=get_enum_type(t_sku_name),
                   help='Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, '
                   'nor can accounts of those SKU names be updated to any other value')
        c.argument('custom_domain',
                   help='User domain assigned to the storage account. Name is the CNAME source. Use "" to clear '
                        'existing value.',
                   validator=validate_custom_domain)
        c.argument('use_subdomain', help='Specify whether to use indirect CNAME validation.',
                   arg_type=get_enum_type(['true', 'false']))
        c.argument('tags', tags_type, default=None)
        c.argument('enable_sftp', arg_type=get_three_state_flag(), min_api='2021-08-01',
                   is_preview=True, help='Enable Secure File Transfer Protocol.')
        c.argument('enable_local_user', arg_type=get_three_state_flag(), min_api='2021-08-01',
                   is_preview=True, help='Enable local user features.')
        c.argument('enable_files_aadds', aadds_type)
        c.argument('enable_files_adds', adds_type)
        c.argument('enable_large_file_share', arg_type=large_file_share_type)
        c.argument('domain_name', domain_name_type)
        c.argument('net_bios_domain_name', net_bios_domain_name_type)
        c.argument('forest_name', forest_name_type)
        c.argument('domain_guid', domain_guid_type)
        c.argument('domain_sid', domain_sid_type)
        c.argument('azure_storage_sid', azure_storage_sid_type)
        c.argument('sam_account_name', sam_account_name_type)
        c.argument('account_type', account_type_type)
        c.argument('routing_choice', routing_choice_type)
        c.argument('publish_microsoft_endpoints', publish_microsoft_endpoints_type)
        c.argument('publish_internet_endpoints', publish_internet_endpoints_type)
        c.argument('allow_blob_public_access', arg_type=get_three_state_flag(), min_api='2019-04-01',
                   help='Allow or disallow public access to all blobs or containers in the storage account. '
                   'The default value for this property is null, which is equivalent to true. When true, containers '
                   'in the account may be configured for public access. Note that setting this property to true does '
                   'not enable anonymous access to any data in the account. The additional step of configuring the '
                   'public access setting for a container is required to enable anonymous access.')
        c.argument('min_tls_version', arg_type=get_enum_type(t_tls_version),
                   help='The minimum TLS version to be permitted on requests to storage. '
                        'The default interpretation is TLS 1.0 for this property')
        c.argument('allow_shared_key_access', allow_shared_key_access_type)
        c.argument('identity_type', arg_type=get_enum_type(t_identity_type), arg_group='Identity',
                   help='The identity type.')
        c.argument('user_identity_id', arg_group='Identity',
                   help='The key is the ARM resource identifier of the identity. Only 1 User Assigned identity is '
                   'permitted here.')
        c.argument('key_expiration_period_in_days', key_expiration_period_in_days_type, is_preview=True)
        c.argument('sas_expiration_period', sas_expiration_period_type, is_preview=True)
        c.argument('allow_cross_tenant_replication', allow_cross_tenant_replication_type)
        c.argument('default_share_permission', default_share_permission_type)
        c.argument('immutability_period_since_creation_in_days',
                   arg_type=immutability_period_since_creation_in_days_type,
                   arg_group='Account Level Immutability')
        c.argument('immutability_policy_state', arg_type=immutability_policy_state_type,
                   arg_group='Account Level Immutability')
        c.argument('allow_protected_append_writes', arg_type=get_three_state_flag(),
                   options_list=['--allow-protected-append-writes', '--allow-append', '-w'],
                   min_api='2021-06-01',
                   help='This property can only be changed for disabled and unlocked time-based retention policies. '
                        'When enabled, new blocks can be written to an append blob while maintaining immutability '
                        'protection and compliance. Only new blocks can be added and any existing blocks cannot be '
                        'modified or deleted.',
                   arg_group='Account Level Immutability')
        c.argument('public_network_access', arg_type=get_enum_type(public_network_access_enum), min_api='2021-06-01',
                   help='Enable or disable public network access to the storage account. '
                        'Possible values include: `Enabled` or `Disabled`.')

    for scope in ['storage account create', 'storage account update']:
        with self.argument_context(scope, arg_group='Customer managed key', min_api='2017-06-01',
                                   resource_type=CUSTOM_MGMT_STORAGE) as c:
            t_key_source = self.get_models('KeySource', resource_type=CUSTOM_MGMT_STORAGE)
            c.argument('encryption_key_name', help='The name of the KeyVault key.', )
            c.argument('encryption_key_vault', help='The Uri of the KeyVault.')
            c.argument('encryption_key_version',
                       help='The version of the KeyVault key to use, which will opt out of implicit key rotation. '
                       'Please use "" to opt in key auto-rotation again.')
            c.argument('encryption_key_source',
                       arg_type=get_enum_type(t_key_source),
                       help='The default encryption key source',
                       validator=validate_encryption_source)
            c.argument('key_vault_user_identity_id', options_list=['--key-vault-user-identity-id', '-u'],
                       min_api='2021-01-01',
                       help='Resource identifier of the UserAssigned identity to be associated with server-side '
                            'encryption on the storage account.')

    for scope in ['storage account create', 'storage account update']:
        with self.argument_context(scope, resource_type=CUSTOM_MGMT_STORAGE, min_api='2017-06-01',
                                   arg_group='Network Rule') as c:
            t_bypass, t_default_action = self.get_models('Bypass', 'DefaultAction',
                                                         resource_type=CUSTOM_MGMT_STORAGE)

            c.argument('bypass', nargs='+', validator=validate_bypass, arg_type=get_enum_type(t_bypass),
                       help='Bypass traffic for space-separated uses.')
            c.argument('default_action', arg_type=get_enum_type(t_default_action),
                       help='Default action to apply when no rule matches.')
            c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
            c.argument('vnet_name', help='Name of a virtual network.', validator=validate_subnet)
            c.argument('action', action_type)

    for item in ['update', 'network-rule']:
        with self.argument_context('storage account {}'.format(item)) as c:
            c.argument('account_name', acct_name_type, options_list=['--name', '-n'])
            c.argument('resource_group_name', required=False, validator=process_resource_group)

    with self.argument_context('storage account network-rule') as c:
        c.argument('account_name', acct_name_type, id_part=None)
        c.argument('ip_address', help='IPv4 address or CIDR range.')
        c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
        c.argument('vnet_name', help='Name of a virtual network.', validator=validate_subnet)
        c.argument('action', help='The action of virtual network rule.')
        c.argument('resource_id', help='The resource id to add in network rule.')
        c.argument('tenant_id', help='The tenant id to add in network rule.')

    with self.argument_context('storage account local-user') as c:
        c.argument('account_name', acct_name_type, options_list='--account-name', id_part=None)
        c.argument('username', options_list=['--username', '--name', '-n'],
                   help='The name of local user. The username must contain lowercase letters and numbers '
                        'only. It must be unique only within the storage account.')

    for item in ['create', 'update']:
        with self.argument_context(f'storage account local-user {item}') as c:
            c.argument('permission_scope', nargs='+', action=PermissionScopeAddAction,
                       help='The permission scope argument list which includes the permissions, service, and resource_name.'
                            'The permissions can be a combination of the below possible values: '
                            'Read(r), Write (w), Delete (d), List (l), and Create (c). '
                            'The service has possible values: blob, file. '
                            'The resource-name is the container name or the file share name. '
                            'Example: --permission-scope permissions=r service=blob resource-name=container1'
                            'Can specify multiple permission scopes: '
                            '--permission-scope permissions=rw service=blob resource-name=container1'
                            '--permission-scope permissions=rwd service=file resource-name=share2')
            c.argument('home_directory', help='The home directory.')
            c.argument('ssh_authorized_key', nargs='+', action=SshPublicKeyAddAction,
                       help='SSH authorized keys for SFTP. Includes an optional description and key. '
                            'The key is the base64 encoded SSH public key , with format: '
                            '<keyType> <keyData> e.g. ssh-rsa AAAABBBB.'
                            'Example: --ssh_authorized_key description=description key="ssh-ras AAAABBBB"'
                            'or --ssh_authorized_key key="ssh-ras AAAABBBB"')
            c.argument('has_shared_key', arg_type=get_three_state_flag(),
                       help='Indicates whether shared key exists. Set it to false to remove existing shared key.')
            c.argument('has_ssh_key', arg_type=get_three_state_flag(),
                       help='Indicates whether ssh key exists. Set it to false to remove existing SSH key.')
            c.argument('has_ssh_password', arg_type=get_three_state_flag(),
                       help='Indicates whether ssh password exists. Set it to false to remove existing SSH password.')

    with self.argument_context('storage blob service-properties update') as c:
        c.argument('delete_retention', arg_type=get_three_state_flag(), arg_group='Soft Delete',
                   help='Enable soft-delete.')
        c.argument('days_retained', type=int, arg_group='Soft Delete',
                   help='Number of days that soft-deleted blob will be retained. Must be in range [1,365].')
        c.argument('static_website', arg_group='Static Website', arg_type=get_three_state_flag(),
                   help='Enable static-website.')
        c.argument('index_document', help='Represents the name of the index document. This is commonly "index.html".',
                   arg_group='Static Website')
        c.argument('error_document_404_path', options_list=['--404-document'], arg_group='Static Website',
                   help='Represent the path to the error document that should be shown when an error 404 is issued,'
                        ' in other words, when a browser requests a page that does not exist.')

    with self.argument_context('storage azcopy blob upload') as c:
        c.extra('destination_container', options_list=['--container', '-c'], required=True,
                help='The upload destination container.')
        c.extra('destination_path', options_list=['--destination', '-d'],
                validator=validate_azcopy_upload_destination_url,
                help='The upload destination path.')
        c.argument('source', options_list=['--source', '-s'],
                   help='The source file path to upload from.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively upload blobs.')
        c.ignore('destination')

    with self.argument_context('storage azcopy blob download') as c:
        c.extra('source_container', options_list=['--container', '-c'], required=True,
                help='The download source container.')
        c.extra('source_path', options_list=['--source', '-s'],
                validator=validate_azcopy_download_source_url,
                help='The download source path.')
        c.argument('destination', options_list=['--destination', '-d'],
                   help='The destination file path to download to.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively download blobs.')
        c.ignore('source')

    with self.argument_context('storage azcopy blob delete') as c:
        c.extra('target_container', options_list=['--container', '-c'], required=True,
                help='The delete target container.')
        c.extra('target_path', options_list=['--target', '-t'],
                validator=validate_azcopy_target_url,
                help='The delete target path.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively delete blobs.')
        c.ignore('target')

    with self.argument_context('storage azcopy blob sync') as c:
        c.extra('destination_container', options_list=['--container', '-c'], required=True,
                help='The sync destination container.')
        c.extra('destination_path', options_list=['--destination', '-d'],
                validator=validate_azcopy_upload_destination_url,
                help='The sync destination path.')
        c.argument('source', options_list=['--source', '-s'],
                   help='The source file path to sync from.')
        c.ignore('destination')

    with self.argument_context('storage azcopy run-command') as c:
        c.positional('command_args', help='Command to run using azcopy. Please start commands with "azcopy ".')

    with self.argument_context('storage blob access') as c:
        c.argument('path', blob_name_type)

    with self.argument_context('storage blob access set') as c:
        c.argument('acl', acl_type, required=True,)
        c.ignore('owner', 'group', 'permissions')

    with self.argument_context('storage blob access update') as c:
        c.argument('acl', acl_type)
        c.argument('owner', help='The owning user for the directory.')
        c.argument('group', help='The owning group for the directory.')
        c.argument('permissions', help='The POSIX access permissions for the file owner,'
                   'the file owning group, and others. Both symbolic (rwxrw-rw-) and 4-digit '
                   'octal notation (e.g. 0766) are supported.')

    with self.argument_context('storage blob list') as c:
        c.argument('include', validator=validate_included_datasets, default='mc')
        c.argument('num_results', arg_type=num_results_type)

    with self.argument_context('storage blob move') as c:
        from ._validators import validate_move_file
        c.argument('source_path', options_list=['--source-blob', '-s'], validator=validate_move_file,
                   help="The source blob name. It should be an absolute path under the container. e.g."
                        "'topdir1/dirsubfoo'.")
        c.argument('new_path', options_list=['--destination-blob', '-d'],
                   help="The destination blob name. It should be an absolute path under the container. e.g."
                        "'topdir1/dirbar'.")
        c.argument('container_name', container_name_type)
        c.ignore('mode')
        c.ignore('marker')

    with self.argument_context('storage blob directory') as c:
        c.argument('directory_path', directory_path_type)
        c.argument('container_name', container_name_type)

    with self.argument_context('storage blob directory access') as c:
        c.argument('path', directory_path_type)

    with self.argument_context('storage blob directory access set') as c:
        c.argument('acl', acl_type, required=True)
        c.ignore('owner', 'group', 'permissions')

    with self.argument_context('storage blob directory access update') as c:
        c.argument('acl', acl_type)
        c.argument('owner', help='The owning user for the directory.')
        c.argument('group', help='The owning group for the directory.')
        c.argument('permissions', help='The POSIX access permissions for the file owner,'
                   'the file owning group, and others. Both symbolic (rwxrw-rw-) and 4-digit '
                   'octal notation (e.g. 0766) are supported.')

    with self.argument_context('storage blob directory create') as c:
        from ._validators import validate_directory_name
        c.argument('posix_permissions', options_list=['--permissions'])
        c.argument('posix_umask', options_list=['--umask'], default='0027',
                   help='Optional and only valid if Hierarchical Namespace is enabled for the account. '
                        'The umask restricts permission settings for file and directory, and will only be applied when '
                        'default Acl does not exist in parent directory. If the umask bit has set, it means that the '
                        'corresponding permission will be disabled. In this way, the resulting permission is given by '
                        'p & ^u, where p is the permission and u is the umask. Only 4-digit octal notation (e.g. 0022) '
                        'is supported here.')
        c.argument('directory_path', directory_path_type, validator=validate_directory_name)

    with self.argument_context('storage blob directory download') as c:
        c.extra('source_container', options_list=['--container', '-c'], required=True,
                help='The download source container.')
        c.extra('source_path', options_list=['--source-path', '-s'], required=True,
                validator=validate_blob_directory_download_source_url,
                help='The download source directory path. It should be an absolute path to container.')
        c.argument('destination', options_list=['--destination-path', '-d'],
                   help='The destination local directory path to download.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively download blobs. If enabled, all the blobs including the blobs in subdirectories '
                        'will be downloaded.')
        c.ignore('source')

    with self.argument_context('storage blob directory exists') as c:
        c.argument('blob_name', directory_path_type, required=True)

    with self.argument_context('storage blob directory list') as c:
        c.argument('include', validator=validate_included_datasets, default='mc')
        c.argument('num_results', arg_type=num_results_type)

    with self.argument_context('storage blob directory metadata') as c:
        c.argument('blob_name', directory_path_type)

    with self.argument_context('storage blob directory move') as c:
        from ._validators import validate_move_directory
        c.argument('new_path', options_list=['--destination-path', '-d'],
                   help='The destination blob directory path. It can be a directory or subdirectory name, e.g. dir, '
                        'dir/subdir. If the destination path exists and is empty, the source will be moved into the '
                        'destination path. If the destination path does not exist, the destination path will be created'
                        ' and overwritten by the source. To control the move operation for nonempty path, you can use '
                        '--move-mode to determine its behavior.')
        c.argument('source_path', options_list=['--source-path', '-s'],
                   help='The source blob directory path.', validator=validate_move_directory)
        c.argument('lease_id', options_list=['--lease-id'],
                   help='A lease ID for destination directory_path. The destination directory_path must have an active '
                        'lease and the lease ID must match.')
        c.argument('mode', options_list=['--move-mode'], arg_type=get_enum_type(["legacy", "posix"]), default="posix",
                   help="Valid only when namespace is enabled. This parameter determines the behavior "
                        "of the move operation. If the destination directory is empty, for both two mode, "
                        "the destination directory will be overwritten. But if the destination directory is not empty, "
                        "in legacy mode the move operation will fail and in posix mode, the source directory will be "
                        "moved into the destination directory. ")

    with self.argument_context('storage blob directory show') as c:
        c.argument('directory_name', directory_path_type)
        c.argument('container_name', container_name_type)
        # c.argument('snapshot', help='The snapshot parameter is an opaque DateTime value that, '
        #                            'when present, specifies the directory snapshot to retrieve.')
        c.ignore('snapshot')
        c.argument('lease_id', help='Required if the blob has an active lease.')
        c.argument('if_match', help="An ETag value, or the wildcard character (*). Specify this header to perform the"
                   "operation only if the resource's ETag matches the value specified")
        c.argument('if_none_match', help="An ETag value, or the wildcard character (*). Specify this header to perform"
                   "the operation only if the resource's ETag does not match the value specified. Specify the wildcard"
                   "character (*) to perform the operation only if the resource does not exist, and fail the operation"
                   "if it does exist.")

    with self.argument_context('storage blob directory upload') as c:
        c.extra('destination_container', options_list=['--container', '-c'], required=True,
                help='The upload destination container.')
        c.extra('destination_path', options_list=['--destination-path', '-d'], required=True,
                validator=validate_blob_directory_upload_destination_url,
                help='The upload destination directory path. It should be an absolute path to container. If the '
                     'specified destination path does not exist, a new directory path will be created.')
        c.argument('source', options_list=['--source', '-s'],
                   help='The source file path to upload from.')
        c.argument('recursive', options_list=['--recursive', '-r'], action='store_true',
                   help='Recursively upload blobs. If enabled, all the blobs including the blobs in subdirectories will'
                        ' be uploaded.')
        c.ignore('destination')

    with self.argument_context('storage file upload') as c:
        t_file_content_settings = self.get_sdk('file.models#ContentSettings')

        c.register_path_argument(default_file_param='local_file_path')
        c.register_content_settings_argument(t_file_content_settings, update=False, guess_from_file='local_file_path',
                                             process_md5=True)
        c.argument('local_file_path', options_list='--source', type=file_type, completer=FilesCompleter(),
                   help='Path of the local file to upload as the file content.')
        c.extra('no_progress', progress_type)
        c.argument('max_connections', type=int, help='Maximum number of parallel connections to use.')
        c.extra('share_name', share_name_type, required=True)
        c.argument('validate_content', action='store_true', min_api='2016-05-31',
                   help='If true, calculates an MD5 hash for each range of the file. The storage service checks the '
                        'hash of the content that has arrived with the hash that was sent. This is primarily valuable '
                        'for detecting bitflips on the wire if using http instead of https as https (the default) will '
                        'already validate. Note that this MD5 hash is not stored with the file.')

    with self.argument_context('storage file upload-batch') as c:
        from ._validators import process_file_upload_batch_parameters
        c.argument('source', options_list=('--source', '-s'), validator=process_file_upload_batch_parameters)
        c.argument('destination', options_list=('--destination', '-d'))
        c.argument('max_connections', arg_group='Upload Control', type=int)
        c.argument('validate_content', action='store_true', min_api='2016-05-31')
        c.register_content_settings_argument(t_file_content_settings, update=False, arg_group='Content Settings',
                                             process_md5=True)
        c.extra('no_progress', progress_type)

    with self.argument_context('storage fs service-properties update', resource_type=CUSTOM_DATA_STORAGE_FILEDATALAKE,
                               min_api='2020-06-12') as c:
        c.argument('delete_retention', arg_type=get_three_state_flag(), arg_group='Soft Delete',
                   help='Enable soft-delete.')
        c.argument('delete_retention_period', type=int, arg_group='Soft Delete',
                   options_list=['--delete-retention-period', '--period'],
                   help='Number of days that soft-deleted fs will be retained. Must be in range [1,365].')
        c.argument('enable_static_website', options_list=['--static-website'], arg_group='Static Website',
                   arg_type=get_three_state_flag(),
                   help='Enable static-website.')
        c.argument('index_document', help='Represent the name of the index document. This is commonly "index.html".',
                   arg_group='Static Website')
        c.argument('error_document_404_path', options_list=['--404-document'], arg_group='Static Website',
                   help='Represent the path to the error document that should be shown when an error 404 is issued,'
                        ' in other words, when a browser requests a page that does not exist.')

    for item in ['list-deleted-path', 'undelete-path']:
        with self.argument_context('storage fs {}'.format(item)) as c:
            c.extra('file_system_name', options_list=['--file-system', '-f'],
                    help="File system name.", required=True)
            c.extra('timeout', timeout_type)

    with self.argument_context('storage fs list-deleted-path') as c:
        c.argument('path_prefix', help='Filter the results to return only paths under the specified path.')
        c.argument('num_results', type=int, help='Specify the maximum number to return.')
        c.argument('marker', help='A string value that identifies the portion of the list of containers to be '
                   'returned with the next listing operation. The operation returns the NextMarker value within '
                   'the response body if the listing operation did not return all containers remaining to be listed '
                   'with the current page. If specified, this generator will begin returning results from the point '
                   'where the previous generator stopped.')
예제 #13
0
        arg_type = CLIArgumentType(choices=CaseInsensitiveList(choices),
                                   action=DefaultAction)
    return arg_type


# GLOBAL ARGUMENT DEFINITIONS

resource_group_name_type = CLIArgumentType(
    options_list=['--resource-group', '-g'],
    completer=get_resource_group_completion_list,
    id_part='resource_group',
    help=
    "Name of resource group. You can configure the default group using `az configure --defaults group=<name>`",
    configured_default='group',
    local_context_attribute=LocalContextAttribute(
        name='resource_group_name',
        actions=[LocalContextAction.SET, LocalContextAction.GET],
        scopes=[ALL]))

name_type = CLIArgumentType(options_list=['--name', '-n'],
                            help='the primary resource name')

edge_zone_type = CLIArgumentType(options_list='--edge-zone',
                                 help='The name of edge zone.',
                                 is_preview=True)


def get_location_type(cli_ctx):
    location_type = CLIArgumentType(
        options_list=['--location', '-l'],
        completer=get_location_completion_list,
        type=get_location_name_type(cli_ctx),
예제 #14
0
def load_arguments(self, _):
    webapp_name_argument_type = CLIArgumentType(options_list=['--app-name', '-app'],
                                                help="name of the web app. You can configure the default using `az configure --defaults web=<name>`",
                                                local_context_attribute=LocalContextAttribute(name='web_name', actions=[LocalContextAction.GET]))
    postgres_server_name_argument_type = CLIArgumentType(options_list=['--server-name', '-s'],
                                                         help="name of the Postgres server or PostgreSql server ID.",
                                                         local_context_attribute=LocalContextAttribute(name='postgres_server_name', actions=[LocalContextAction.GET]))
    postgres_database_name_argument_type = CLIArgumentType(options_list=['--database-name', '-db'],
                                                           help="Database name",
                                                           local_context_attribute=LocalContextAttribute(name='postgres_database_name', actions=[LocalContextAction.GET]))
    postgres_database_username_argument_type = CLIArgumentType(options_list=['--user-name', '-user'],
                                                               help="User name of the database. Only valid when auth type is secret",
                                                               local_context_attribute=LocalContextAttribute(name='postgres_admin_user_name', actions=[LocalContextAction.GET]))
    with self.argument_context('connect webapp') as c:
        c.argument('resource_group', options_list=['--resource-group', '-g'], help='Resource group to provision services.')
        c.argument('name', options_list=['--connection-name', '-n'], help='Connection name')
        c.argument('appname', options_list=['--app-name', '-app'], help='Webapp name')
        c.argument('sql', options_list=['--sql-server', '-sql'], help='SQL server name in the same resource group or SQL server ID')
        c.argument('mysql', options_list=['--mysql-server', '-mysql'], help='SQL server name in the same resource group or mysql server ID')
        c.argument('postgres', options_list=['--postgresql-server', '-postgres'], help ='PostgreSql server name in the same resource group or PostgreSql server ID')
        c.argument('cosmos', options_list=['--cosmos-account', '-cosmos'], help='CosmosDB Account name')
        c.argument('database', options_list=['--database-name', '-db'], help='Database name')
        c.argument(
            'authtype', options_list=['--auth-type', '-auth'], help='Auth type could be MSI, SP, Secret',
            arg_type=get_enum_type(AuthType)
        )
        c.argument('permission', options_list=['--permission', '-per'], help='The permission assigned to the identity or SP')
        c.argument('client_id', options_list=['--client-id', '-cid'], help='Client Id assigned to webapp. Only valid when auth type is SP')
        c.argument('client_secret', options_list=['--client-secret', '-secret'], help='Client secret of the client id. Only valid when auth type is SP')
        c.argument('username', options_list=['--user-name', '-user'], help='User name of the database. Only valid when auth type is secret')
        c.argument('password', options_list=['--password', '-pwd'], help='Password of the database. Only valid when auth type is secret')
        c.argument('keyvault', options_list=['--keyvault', '-kvt'], help='Keyvault name in the same resource group.')

    with self.argument_context('connect webapp postgres') as c:
        c.argument('resource_group', arg_type=resource_group_name_type)
        c.argument('name',  options_list=['--connection-name', '-n'], help='Connection name')
        c.argument('appname', arg_type=webapp_name_argument_type)
        c.argument('server', arg_type=postgres_server_name_argument_type)
        c.argument('database', arg_type=postgres_database_name_argument_type)
        c.argument(
            'authtype', options_list=['--auth-type', '-auth'], help='Auth type could be MSI, SP, Secret',
            arg_type=get_enum_type(AuthType))
        c.argument('permission', options_list=['--permission', '-per'], help='The permission assigned to the identity or SP')
        c.argument('client_id', options_list=['--client-id', '-cid'], help='Client Id assigned to webapp. Only valid when auth type is SP')
        c.argument('client_secret', options_list=['--client-secret', '-secret'], help='Client secret of the client id. Only valid when auth type is SP')
        c.argument('username', arg_type=postgres_database_username_argument_type)
        c.argument('password', options_list=['--password', '-pwd'], help='Password of the database. Only valid when auth type is secret')

    with self.argument_context('connect springcloud') as c:
        c.argument('resource_group', options_list=['--resource-group', '-g'], help='Resource group to provision services.')
        c.argument('name', options_list=['--connection-name', '-n'], help='Connection name')
        c.argument('springcloud', options_list=['--spring-cloud', '-spc'], help='spring cloud name')
        c.argument('appname', options_list=['--app-name', '-app'], help='Webapp name')
        c.argument('mysql', options_list=['--mysql-server', '-mysql'], help='SQL server name in the same resource group or mysql server ID')
        c.argument('cosmos', options_list=['--cosmos-account', '-cosmos'], help='CosmosDB Account name')
        c.argument('database', options_list=['--database-name', '-db'], help='Database name')
        c.argument('username', options_list=['--user-name', '-user'], help='User name of the database. Only valid when auth type is secret')
        c.argument('password', options_list=['--password', '-pwd'], help='Password of the database. Only valid when auth type is secret')

    with self.argument_context('connect function') as c:
        c.argument('resource_group', options_list=['--resource-group', '-g'], help='Resource group to provision services.')
        c.argument('name', options_list=['--connection-name', '-n'], help='Connection name')
        c.argument('appname', options_list=['--app-name', '-app'], help='Function app name')
        c.argument('function_name', options_list=['--function-name', '-func'], help='Function name')
        c.argument('signalR', options_list=['--signalr', '-signalr'], help='SignalR service name')
        c.argument('binding', options_list=['--binding-type', '-binding'], help='The binding type of the function: input or output')

    with self.argument_context('connect validate') as c:
        c.argument('resource_group', arg_type=resource_group_name_type)
        c.argument('name', options_list=['--connection-name', '-n'], help='Connection name')

    with self.argument_context('connect get') as c:
        c.argument('resource_group', arg_type=resource_group_name_type)
        c.argument('name', options_list=['--connection-name', '-n'], help='Connection name')
예제 #15
0
        arg_type = CLIArgumentType(choices=CaseInsensitiveList(choices),
                                   action=DefaultAction)
    return arg_type


# GLOBAL ARGUMENT DEFINITIONS

resource_group_name_type = CLIArgumentType(
    options_list=['--resource-group', '-g'],
    completer=get_resource_group_completion_list,
    id_part='resource_group',
    help=
    "Name of resource group. You can configure the default group using `az configure --defaults group=<name>`",
    configured_default='group',
    local_context_attribute=LocalContextAttribute(name='resource_group_name',
                                                  actions=[STORE, USE],
                                                  scopes=[ALL]))

name_type = CLIArgumentType(options_list=['--name', '-n'],
                            help='the primary resource name')


def get_location_type(cli_ctx):
    location_type = CLIArgumentType(
        options_list=['--location', '-l'],
        completer=get_location_completion_list,
        type=get_location_name_type(cli_ctx),
        help="Location. Values from: `az account list-locations`. "
        "You can configure the default location using `az configure --defaults location=<location>`.",
        metavar='LOCATION',
        configured_default='location')
예제 #16
0
def load_arguments(self, _):  # pylint: disable=too-many-locals, too-many-statements, too-many-lines
    from argcomplete.completers import FilesCompleter

    from knack.arguments import ignore_type, CLIArgumentType

    from azure.cli.core.commands.parameters import get_resource_name_completion_list

    from .sdkutil import get_table_data_type
    from .completers import get_storage_name_completion_list

    acct_name_type = CLIArgumentType(options_list=['--account-name', '-n'], help='The storage account name.',
                                     id_part='name',
                                     completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'),
                                     local_context_attribute=LocalContextAttribute(
                                         name='storage_account_name', actions=[LocalContextAction.GET]))

    t_base_blob_service = self.get_sdk('blob.baseblobservice#BaseBlobService')
    t_file_service = self.get_sdk('file#FileService')
    t_table_service = get_table_data_type(self.cli_ctx, 'table', 'TableService')
    t_blob_tier = self.get_sdk('_generated.models._azure_blob_storage_enums#AccessTierOptional',
                               resource_type=CUSTOM_DATA_STORAGE_BLOB)
    t_rehydrate_priority = self.get_sdk('_generated.models._azure_blob_storage_enums#RehydratePriority',
                                        resource_type=CUSTOM_DATA_STORAGE_BLOB)

    blob_name_type = CLIArgumentType(options_list=['--blob-name', '-b'], help='The blob name.',
                                     completer=get_storage_name_completion_list(t_base_blob_service, 'list_blobs',
                                                                                parent='container_name'))

    container_name_type = CLIArgumentType(options_list=['--container-name', '-c'], help='The container name.',
                                          completer=get_storage_name_completion_list(t_base_blob_service,
                                                                                     'list_containers'))
    directory_type = CLIArgumentType(options_list=['--directory-name', '-d'], help='The directory name.',
                                     completer=get_storage_name_completion_list(t_file_service,
                                                                                'list_directories_and_files',
                                                                                parent='share_name'))
    share_name_type = CLIArgumentType(options_list=['--share-name', '-s'], help='The file share name.',
                                      completer=get_storage_name_completion_list(t_file_service, 'list_shares'))
    table_name_type = CLIArgumentType(options_list=['--table-name', '-t'],
                                      completer=get_storage_name_completion_list(t_table_service, 'list_tables'))
    progress_type = CLIArgumentType(help='Include this flag to disable progress reporting for the command.',
                                    action='store_true')
    sas_help = 'The permissions the SAS grants. Allowed values: {}. Do not use if a stored access policy is ' \
               'referenced with --policy-name that specifies this value. Can be combined.'

    lease_type = CLIArgumentType(
        options_list='--lease-id', help='Required if the blob has an active lease.'
    )

    snapshot_type = CLIArgumentType(
        help='The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot '
        'to retrieve.'
    )

    tags_type = CLIArgumentType(
        nargs='*', validator=validate_tags, min_api='2019-12-12', is_preview=True,
        help='space-separated tags: key[=value] [key[=value] ...]. Tags are case-sensitive. The tag set may '
        'contain at most 10 tags.  Tag keys must be between 1 and 128 characters, and tag values must be '
        'between 0 and 256 characters. Valid tag key and value characters include: lowercase and uppercase '
        'letters, digits (0-9), space (` `), plus (+), minus (-), period (.), solidus (/), colon (:), equals '
        '(=), underscore (_).'
    )

    marker_type = CLIArgumentType(
        help='A string value that identifies the portion of the list of containers to be '
             'returned with the next listing operation. The operation returns the NextMarker value within '
             'the response body if the listing operation did not return all containers remaining to be listed '
             'with the current page. If specified, this generator will begin returning results from the point '
             'where the previous generator stopped.')

    num_results_type = CLIArgumentType(
        default=5000, validator=validate_storage_data_plane_list, options_list='--num-results',
        help='Specify the maximum number to return. If the request does not specify '
        'num_results, or specifies a value greater than 5000, the server will return up to 5000 items. Note that '
        'if the listing operation crosses a partition boundary, then the service will return a continuation token '
        'for retrieving the remaining of the results. Provide "*" to return all.'
    )

    version_id_type = CLIArgumentType(
        help='An optional blob version ID. This parameter is only for versioning enabled account. ',
        min_api='2019-12-12', is_preview=True
    )  # Fix preview display

    tier_type = CLIArgumentType(
        arg_type=get_enum_type(t_blob_tier), min_api='2019-02-02',
        help='The tier value to set the blob to. For page blob, the tier correlates to the size of the blob '
             'and number of allowed IOPS. Possible values are P10, P15, P20, P30, P4, P40, P50, P6, P60, P70, P80 '
             'and this is only applicable to page blobs on premium storage accounts; For block blob, possible '
             'values are Archive, Cool and Hot. This is only applicable to block blobs on standard storage accounts.'
    )

    rehydrate_priority_type = CLIArgumentType(
        arg_type=get_enum_type(t_rehydrate_priority), options_list=('--rehydrate-priority', '-r'),
        min_api='2019-02-02',
        help='Indicate the priority with which to rehydrate an archived blob.')

    tags_condition_type = CLIArgumentType(
        options_list='--tags-condition', min_api='2019-12-12',
        help='Specify a SQL where clause on blob tags to operate only on blobs with a matching value.')
    timeout_type = CLIArgumentType(
        help='Request timeout in seconds. Applies to each call to the service.', type=int
    )
    t_delete_snapshots = self.get_sdk('_generated.models#DeleteSnapshotsOptionType',
                                      resource_type=CUSTOM_DATA_STORAGE_BLOB)
    delete_snapshots_type = CLIArgumentType(
        arg_type=get_enum_type(t_delete_snapshots),
        help='Required if the blob has associated snapshots. "only": Deletes only the blobs snapshots. '
             '"include": Deletes the blob along with all snapshots.')
    overwrite_type = CLIArgumentType(
        arg_type=get_three_state_flag(),
        help='Whether the blob to be uploaded should overwrite the current data. If True, upload_blob will '
        'overwrite the existing data. If set to False, the operation will fail with ResourceExistsError. '
        'The exception to the above is with Append blob types: if set to False and the data already exists, '
        'an error will not be raised and the data will be appended to the existing blob. If set '
        'overwrite=True, then the existing append blob will be deleted, and a new one created. '
        'Defaults to False.')

    with self.argument_context('storage') as c:
        c.argument('container_name', container_name_type)
        c.argument('directory_name', directory_type)
        c.argument('share_name', share_name_type)
        c.argument('table_name', table_name_type)
        c.argument('retry_wait', options_list=('--retry-interval',))
        c.ignore('progress_callback')
        c.argument('metadata', nargs='+',
                   help='Metadata in space-separated key=value pairs. This overwrites any existing metadata.',
                   validator=validate_metadata)
        c.argument('timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

    with self.argument_context('storage account blob-service-properties show',
                               resource_type=CUSTOM_MGMT_STORAGE) as c:
        c.argument('account_name', acct_name_type, id_part=None)
        c.argument('resource_group_name', required=False, validator=process_resource_group)

    with self.argument_context('storage account blob-service-properties update',
                               resource_type=CUSTOM_MGMT_STORAGE) as c:
        from azure.cli.command_modules.storage._validators import get_api_version_type, \
            validator_change_feed_retention_days
        c.argument('account_name', acct_name_type, id_part=None)
        c.argument('resource_group_name', required=False, validator=process_resource_group)
        c.argument('enable_change_feed', arg_type=get_three_state_flag(), min_api='2019-04-01',
                   arg_group='Change Feed Policy')
        c.argument('change_feed_retention_days', is_preview=True,
                   options_list=['--change-feed-retention-days', '--change-feed-days'],
                   type=int, min_api='2019-06-01', arg_group='Change Feed Policy',
                   validator=validator_change_feed_retention_days,
                   help='Indicate the duration of changeFeed retention in days. '
                        'Minimum value is 1 day and maximum value is 146000 days (400 years). '
                        'A null value indicates an infinite retention of the change feed.'
                        '(Use `--enable-change-feed` without `--change-feed-days` to indicate null)')
        c.argument('enable_container_delete_retention',
                   arg_type=get_three_state_flag(),
                   options_list=['--enable-container-delete-retention', '--container-retention'],
                   arg_group='Container Delete Retention Policy', min_api='2019-06-01',
                   help='Enable container delete retention policy for container soft delete when set to true. '
                        'Disable container delete retention policy when set to false.')
        c.argument('container_delete_retention_days',
                   options_list=['--container-delete-retention-days', '--container-days'],
                   type=int, arg_group='Container Delete Retention Policy',
                   min_api='2019-06-01', validator=validate_container_delete_retention_days,
                   help='Indicate the number of days that the deleted container should be retained. The minimum '
                        'specified value can be 1 and the maximum value can be 365.')
        c.argument('enable_delete_retention', arg_type=get_three_state_flag(), arg_group='Delete Retention Policy',
                   min_api='2018-07-01')
        c.argument('delete_retention_days', type=int, arg_group='Delete Retention Policy',
                   validator=validate_delete_retention_days, min_api='2018-07-01')
        c.argument('enable_restore_policy', arg_type=get_three_state_flag(), arg_group='Restore Policy',
                   min_api='2019-06-01', help="Enable blob restore policy when it set to true.")
        c.argument('restore_days', type=int, arg_group='Restore Policy',
                   min_api='2019-06-01', help="The number of days for the blob can be restored. It should be greater "
                   "than zero and less than Delete Retention Days.")
        c.argument('enable_versioning', arg_type=get_three_state_flag(), help='Versioning is enabled if set to true.',
                   min_api='2019-06-01')
        c.argument('enable_last_access_tracking', arg_type=get_three_state_flag(), min_api='2019-06-01',
                   options_list=['--enable-last-access-tracking', '-t'],
                   help='When set to true last access time based tracking policy is enabled.')
        c.argument('default_service_version', options_list=['--default-service-version', '-d'],
                   type=get_api_version_type(), min_api='2018-07-01',
                   help="Indicate the default version to use for requests to the Blob service if an incoming request's "
                        "version is not specified.")

    with self.argument_context('storage blob') as c:
        c.argument('blob_name', options_list=('--name', '-n'), arg_type=blob_name_type)
        c.argument('destination_path', help='The destination path that will be appended to the blob name.')
        c.argument('socket_timeout', deprecate_info=c.deprecate(hide=True),
                   help='The socket timeout(secs), used by the service to regulate data flow.')

    with self.argument_context('storage blob copy') as c:
        c.argument('container_name', container_name_type, options_list=('--destination-container', '-c'))
        c.argument('blob_name', blob_name_type, options_list=('--destination-blob', '-b'),
                   help='Name of the destination blob. If the exists, it will be overwritten.')

    with self.argument_context('storage blob copy start') as c:
        from ._validators import validate_source_url

        c.register_blob_arguments()
        c.register_precondition_options()
        c.register_precondition_options(prefix='source_')
        c.register_source_uri_arguments(validator=validate_source_url)

        c.ignore('incremental_copy')
        c.argument('if_match', options_list=['--destination-if-match'])
        c.argument('if_modified_since', options_list=['--destination-if-modified-since'])
        c.argument('if_none_match', options_list=['--destination-if-none-match'])
        c.argument('if_unmodified_since', options_list=['--destination-if-unmodified-since'])
        c.argument('if_tags_match_condition', options_list=['--destination-tags-condition'])

        c.argument('blob_name', options_list=['--destination-blob', '-b'], required=True,
                   help='Name of the destination blob. If the exists, it will be overwritten.')
        c.argument('container_name', options_list=['--destination-container', '-c'], required=True,
                   help='The container name.')
        c.extra('destination_lease', options_list='--destination-lease-id',
                help='The lease ID specified for this header must match the lease ID of the estination blob. '
                'If the request does not include the lease ID or it is not valid, the operation fails with status '
                'code 412 (Precondition Failed).')
        c.extra('source_lease', options_list='--source-lease-id', arg_group='Copy Source',
                help='Specify this to perform the Copy Blob operation only if the lease ID given matches the '
                'active lease ID of the source blob.')
        c.extra('rehydrate_priority', rehydrate_priority_type)
        c.extra('requires_sync', arg_type=get_three_state_flag(),
                help='Enforce that the service will not return a response until the copy is complete.')
        c.extra('tier', tier_type)
        c.extra('tags', tags_type)

    with self.argument_context('storage blob copy start-batch', arg_group='Copy Source') as c:
        from ._validators import get_source_file_or_blob_service_client

        c.argument('source_client', ignore_type, validator=get_source_file_or_blob_service_client)

        c.extra('source_account_name')
        c.extra('source_account_key')
        c.extra('source_uri')
        c.argument('source_sas')
        c.argument('source_container')
        c.argument('source_share')

    with self.argument_context('storage blob delete') as c:
        c.register_blob_arguments()
        c.register_precondition_options()

        c.extra('lease', lease_type)
        c.extra('snapshot', snapshot_type)
        c.extra('version_id', version_id_type)
        c.argument('delete_snapshots', delete_snapshots_type)

    with self.argument_context('storage blob delete-batch') as c:
        c.register_precondition_options()

        c.ignore('container_name')
        c.argument('source', options_list=('--source', '-s'))
        c.argument('delete_snapshots', delete_snapshots_type)
        c.argument('lease_id', help='The active lease id for the blob.')

    with self.argument_context('storage blob download') as c:
        c.register_blob_arguments()
        c.register_precondition_options()
        c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter(),
                   help='Path of file to write out to.')
        c.extra('start_range', type=int,
                help='Start of byte range to use for downloading a section of the blob. If no end_range is given, '
                'all bytes after the start_range will be downloaded. The start_range and end_range params are '
                'inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of blob.')
        c.extra('end_range', type=int,
                help='End of byte range to use for downloading a section of the blob. If end_range is given, '
                'start_range must be provided. The start_range and end_range params are inclusive. Ex: start_range=0, '
                'end_range=511 will download first 512 bytes of blob.')
        c.extra('no_progress', progress_type, validator=add_download_progress_callback)
        c.extra('snapshot', snapshot_type)
        c.extra('lease', lease_type)
        c.extra('version_id', version_id_type)
        c.extra('max_concurrency', options_list='--max-connections', type=int, default=2,
                help='The number of parallel connections with which to download.')
        c.argument('open_mode', help='Mode to use when opening the file. Note that specifying append only open_mode '
                   'prevents parallel download. So, max_connections must be set to 1 if this open_mode is used.')
        c.extra('validate_content', action='store_true', min_api='2016-05-31',
                help='If true, calculates an MD5 hash for each chunk of the blob. The storage service checks the '
                'hash of the content that has arrived with the hash that was sent. This is primarily valuable for '
                'detecting bitflips on the wire if using http instead of https, as https (the default), will already '
                'validate. Note that this MD5 hash is not stored with the blob. Also note that if enabled, the '
                'memory-efficient algorithm will not be used because computing the MD5 hash requires buffering '
                'entire blocks, and doing so defeats the purpose of the memory-efficient algorithm.')

    with self.argument_context('storage blob download-batch') as c:
        # c.register_precondition_options()
        c.ignore('container_name')
        c.argument('destination', options_list=('--destination', '-d'))
        c.argument('source', options_list=('--source', '-s'))
        c.extra('max_concurrency', options_list='--max-connections', type=int, default=2,
                help='The number of parallel connections with which to download.')
        c.extra('no_progress', progress_type)

    with self.argument_context('storage blob exists') as c:
        c.register_blob_arguments()

    with self.argument_context('storage blob filter') as c:
        c.argument('filter_expression', options_list=['--tag-filter'])

    with self.argument_context('storage blob generate-sas') as c:
        from .completers import get_storage_acl_name_completion_list

        t_blob_permissions = self.get_sdk('_models#BlobSasPermissions', resource_type=CUSTOM_DATA_STORAGE_BLOB)
        c.register_sas_arguments()
        c.argument('cache_control', help='Response header value for Cache-Control when resource is accessed'
                                         'using this shared access signature.')
        c.argument('content_disposition', help='Response header value for Content-Disposition when resource is accessed'
                                               'using this shared access signature.')
        c.argument('content_encoding', help='Response header value for Content-Encoding when resource is accessed'
                                            'using this shared access signature.')
        c.argument('content_language', help='Response header value for Content-Language when resource is accessed'
                                            'using this shared access signature.')
        c.argument('content_type', help='Response header value for Content-Type when resource is accessed'
                                        'using this shared access signature.')
        c.argument('full_uri', action='store_true',
                   help='Indicate that this command return the full blob URI and the shared access signature token.')
        c.argument('as_user', min_api='2018-11-09', action='store_true',
                   validator=as_user_validator,
                   help="Indicates that this command return the SAS signed with the user delegation key. "
                        "The expiry parameter and '--auth-mode login' are required if this argument is specified. ")
        c.argument('id', options_list='--policy-name',
                   help='The name of a stored access policy within the container\'s ACL.',
                   completer=get_storage_acl_name_completion_list(t_base_blob_service, 'container_name',
                                                                  'get_container_acl'))
        c.argument('ip', help='Specify an IP address or a range of IP addresses from which to accept requests. '
                   'If the IP address from which the request originates does not match the IP address or address range '
                   'specified on the SAS token, the request is not authenticated. For example, specifying ip=168.1.5.65'
                   ' or ip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.')
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format(get_permission_help_string(t_blob_permissions)),
                   validator=get_permission_validator(t_blob_permissions))
        c.argument('snapshot', snapshot_type)
        c.ignore('sas_token')
        c.argument('version_id', version_id_type)

    with self.argument_context('storage blob lease') as c:
        c.argument('blob_name', arg_type=blob_name_type)

    with self.argument_context('storage blob lease acquire') as c:
        c.register_precondition_options()
        c.register_lease_blob_arguments()
        c.extra('lease_id', options_list='--proposed-lease-id', help='Proposed lease ID, in a GUID string format. '
                'The Blob service returns 400 (Invalid request) if the proposed lease ID is not in the correct format.')
        c.argument('lease_duration', help='Specify the duration of the lease, in seconds, or negative one (-1) for '
                   'a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease '
                   'duration cannot be changed using renew or change. Default is -1 (infinite lease)', type=int)
        c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob lease break') as c:
        c.register_precondition_options()
        c.register_lease_blob_arguments()
        c.argument('lease_break_period', type=int,
                   help="This is the proposed duration of seconds that the lease should continue before it is broken, "
                   "between 0 and 60 seconds. This break period is only used if it is shorter than the time remaining "
                   "on the lease. If longer, the time remaining on the lease is used. A new lease will not be "
                   "available before the break period has expired, but the lease may be held for longer than the break "
                   "period. If this header does not appear with a break operation, a fixed-duration lease breaks after "
                   "the remaining lease period elapses, and an infinite lease breaks immediately.")
        c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob lease change') as c:
        c.register_precondition_options()
        c.register_lease_blob_arguments()
        c.extra('proposed_lease_id', help='Proposed lease ID, in a GUID string format. The Blob service returns 400 '
                '(Invalid request) if the proposed lease ID is not in the correct format.', required=True)
        c.extra('lease_id', help='Required if the blob has an active lease.', required=True)
        c.extra('if_tags_match_condition', tags_condition_type)

    for item in ['release', 'renew']:
        with self.argument_context('storage blob lease {}'.format(item)) as c:
            c.register_precondition_options()
            c.register_lease_blob_arguments()
            c.extra('lease_id', help='Required if the blob has an active lease.', required=True)
            c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob list') as c:
        from .track2_util import get_include_help_string
        t_blob_include = self.get_sdk('_generated.models._azure_blob_storage_enums#ListBlobsIncludeItem',
                                      resource_type=CUSTOM_DATA_STORAGE_BLOB)
        c.register_container_arguments()
        c.argument('delimiter',
                   help='When the request includes this parameter, the operation returns a BlobPrefix element in the '
                   'result list that acts as a placeholder for all blobs whose names begin with the same substring '
                   'up to the appearance of the delimiter character. The delimiter may be a single character or a '
                   'string.')
        c.argument('include', help="Specify one or more additional datasets to include in the response. "
                   "Options include: {}. Can be combined.".format(get_include_help_string(t_blob_include)),
                   validator=validate_included_datasets_v2)
        c.argument('marker', arg_type=marker_type)
        c.argument('num_results', arg_type=num_results_type)
        c.argument('prefix',
                   help='Filter the results to return only blobs whose name begins with the specified prefix.')
        c.argument('show_next_marker', action='store_true', is_preview=True,
                   help='Show nextMarker in result when specified.')

    for item in ['show', 'update']:
        with self.argument_context('storage blob metadata {}'.format(item), resource_type=CUSTOM_DATA_STORAGE_BLOB) \
                as c:
            c.register_blob_arguments()
            c.register_precondition_options()
            c.extra('lease', lease_type)
            c.extra('snapshot', snapshot_type)
            c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob service-properties delete-policy update') as c:
        c.argument('enable', arg_type=get_enum_type(['true', 'false']), help='Enables/disables soft-delete.')
        c.argument('days_retained', type=int,
                   help='Number of days that soft-deleted blob will be retained. Must be in range [1,365].')

    with self.argument_context('storage blob service-properties update', min_api='2018-03-28') as c:
        c.argument('delete_retention', arg_type=get_three_state_flag(), arg_group='Soft Delete',
                   help='Enables soft-delete.')
        c.argument('delete_retention_period', type=int, arg_group='Soft Delete',
                   help='Number of days that soft-deleted blob will be retained. Must be in range [1,365].')
        c.argument('static_website', arg_group='Static Website', arg_type=get_three_state_flag(),
                   help='Enables static-website.')
        c.argument('index_document', help='The default name of the index page under each directory.',
                   arg_group='Static Website')
        c.argument('error_document_404_path', options_list=['--404-document'], arg_group='Static Website',
                   help='The absolute path of the custom 404 page.')
        c.argument('default_index_document_path', options_list='--default-index-path', is_preview=True,
                   help='Absolute path of the default index page.',
                   arg_group='Static Website')

    with self.argument_context('storage blob set-tier', resource_type=CUSTOM_DATA_STORAGE_BLOB) as c:
        c.register_blob_arguments()

        c.argument('blob_type', options_list=('--type', '-t'), arg_type=get_enum_type(('block', 'page')))
        c.extra('tier', tier_type, validator=blob_tier_validator, required=True)
        c.argument('rehydrate_priority', rehydrate_priority_type, is_preview=True)
        c.extra('version_id', version_id_type)
        c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob show') as c:
        c.register_blob_arguments()
        c.register_precondition_options()
        c.extra('snapshot', snapshot_type)
        c.extra('lease', lease_type)
        c.argument('version_id', version_id_type)

    with self.argument_context('storage blob snapshot') as c:
        c.register_blob_arguments()
        c.register_precondition_options()
        c.extra('lease', lease_type)
        c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob undelete', resource_type=CUSTOM_DATA_STORAGE_BLOB) as c:
        c.register_blob_arguments()

    with self.argument_context('storage blob tag list') as c:
        c.register_blob_arguments()
        c.extra('version_id', version_id_type)
        c.extra('snapshot', snapshot_type)
        c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob tag set') as c:
        c.register_blob_arguments()
        c.extra('version_id', version_id_type)
        c.argument('tags', tags_type, required=True)
        c.extra('if_tags_match_condition', tags_condition_type)

    with self.argument_context('storage blob upload') as c:
        from ._validators import validate_encryption_scope_client_params, validate_upload_blob

        from .sdkutil import get_blob_types

        t_blob_content_settings = self.get_sdk('_models#ContentSettings', resource_type=CUSTOM_DATA_STORAGE_BLOB)

        c.register_blob_arguments()
        c.register_precondition_options()
        c.register_content_settings_argument(t_blob_content_settings, update=False, arg_group="Content Control")

        c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter(),
                   help='Path of the file to upload as the blob content.', validator=validate_upload_blob)
        c.argument('data', help='The blob data to upload.', required=False, is_preview=True, min_api='2019-02-02')
        c.argument('length', type=int, help='Number of bytes to read from the stream. This is optional, but should be '
                   'supplied for optimal performance. Cooperate with --data.', is_preview=True, min_api='2019-02-02')
        c.argument('overwrite', arg_type=get_three_state_flag(), arg_group="Additional Flags", is_preview=True,
                   help='Whether the blob to be uploaded should overwrite the current data. If True, blob upload '
                   'operation will  overwrite the existing data. If set to False, the operation will fail with '
                   'ResourceExistsError. The exception to the above is with Append blob types: if set to False and the '
                   'data already exists, an error will not be raised and the data will be appended to the existing '
                   'blob. If set overwrite=True, then the existing append blob will be deleted, and a new one created. '
                   'Defaults to False.')
        c.argument('max_connections', type=int, arg_group="Additional Flags",
                   help='Maximum number of parallel connections to use when the blob size exceeds 64MB.')
        c.extra('maxsize_condition', type=int, arg_group="Content Control",
                help='The max length in bytes permitted for the append blob.')
        c.argument('blob_type', options_list=('--type', '-t'), validator=validate_blob_type,
                   arg_type=get_enum_type(get_blob_types()), arg_group="Additional Flags")
        c.argument('validate_content', action='store_true', min_api='2016-05-31', arg_group="Content Control")
        c.extra('no_progress', progress_type, validator=add_upload_progress_callback, arg_group="Additional Flags")
        c.extra('tier', tier_type, validator=blob_tier_validator, arg_group="Additional Flags")
        c.argument('encryption_scope', validator=validate_encryption_scope_client_params,
                   help='A predefined encryption scope used to encrypt the data on the service.',
                   arg_group="Additional Flags")
        c.argument('lease_id', help='Required if the blob has an active lease.')
        c.extra('tags', arg_type=tags_type, arg_group="Additional Flags")
        c.argument('metadata', arg_group="Additional Flags")
        c.argument('timeout', arg_group="Additional Flags")

    with self.argument_context('storage blob upload-batch') as c:
        from .sdkutil import get_blob_types

        t_blob_content_settings = self.get_sdk('_models#ContentSettings', resource_type=CUSTOM_DATA_STORAGE_BLOB)
        c.register_precondition_options()
        c.register_content_settings_argument(t_blob_content_settings, update=False, arg_group='Content Control')
        c.ignore('source_files', 'destination_container_name')

        c.argument('source', options_list=('--source', '-s'))
        c.argument('destination', options_list=('--destination', '-d'))
        c.argument('max_connections', type=int,
                   help='Maximum number of parallel connections to use when the blob size exceeds 64MB.')
        c.argument('maxsize_condition', arg_group='Content Control')
        c.argument('validate_content', action='store_true', min_api='2016-05-31', arg_group='Content Control')
        c.argument('blob_type', options_list=('--type', '-t'), arg_type=get_enum_type(get_blob_types()))
        c.extra('no_progress', progress_type)
        c.extra('tier', tier_type, is_preview=True)
        c.extra('overwrite', overwrite_type, is_preview=True)

    with self.argument_context('storage container') as c:
        c.argument('container_name', container_name_type, options_list=('--name', '-n'))

    with self.argument_context('storage container generate-sas') as c:
        from .completers import get_storage_acl_name_completion_list
        t_container_permissions = self.get_sdk('_models#ContainerSasPermissions',
                                               resource_type=CUSTOM_DATA_STORAGE_BLOB)
        c.register_sas_arguments()
        c.argument('id', options_list='--policy-name',
                   help='The name of a stored access policy within the container\'s ACL.',
                   completer=get_storage_acl_name_completion_list(t_container_permissions, 'container_name',
                                                                  'get_container_acl'))
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format(get_permission_help_string(t_container_permissions)),
                   validator=get_permission_validator(t_container_permissions))
        c.argument('cache_control', help='Response header value for Cache-Control when resource is accessed'
                                         'using this shared access signature.')
        c.argument('content_disposition', help='Response header value for Content-Disposition when resource is accessed'
                                               'using this shared access signature.')
        c.argument('content_encoding', help='Response header value for Content-Encoding when resource is accessed'
                                            'using this shared access signature.')
        c.argument('content_language', help='Response header value for Content-Language when resource is accessed'
                                            'using this shared access signature.')
        c.argument('content_type', help='Response header value for Content-Type when resource is accessed'
                                        'using this shared access signature.')
        c.argument('as_user', min_api='2018-11-09', action='store_true',
                   validator=as_user_validator,
                   help="Indicates that this command return the SAS signed with the user delegation key. "
                        "The expiry parameter and '--auth-mode login' are required if this argument is specified. ")
        c.ignore('sas_token')
        c.argument('full_uri', action='store_true', is_preview=True,
                   help='Indicate that this command return the full blob URI and the shared access signature token.')

    with self.argument_context('storage container list') as c:
        c.extra('timeout', timeout_type)
        c.argument('marker', arg_type=marker_type)
        c.argument('num_results', arg_type=num_results_type)
        c.argument('prefix',
                   help='Filter the results to return only blobs whose name begins with the specified prefix.')
        c.argument('include_metadata', arg_type=get_three_state_flag(),
                   help='Specify that container metadata to be returned in the response.')
        c.argument('show_next_marker', action='store_true', is_preview=True,
                   help='Show nextMarker in result when specified.')
        c.argument('include_deleted', arg_type=get_three_state_flag(), min_api='2020-02-10',
                   help='Specify that deleted containers to be returned in the response. This is for container restore '
                   'enabled account. The default value is `False`')

    with self.argument_context('storage container restore') as c:
        c.argument('deleted_container_name', options_list=['--name', '-n'],
                   help='Specify the name of the deleted container to restore.')
        c.argument('deleted_container_version', options_list=['--deleted-version'],
                   help='Specify the version of the deleted container to restore.')
        c.argument('new_name', help='The new name for the deleted container to be restored to.')
        c.extra('timeout', timeout_type)
예제 #17
0
def load_arguments(self, _):
    from argcomplete.completers import FilesCompleter

    from azure.mgmt.resource.resources.models import DeploymentMode
    from azure.mgmt.resource.locks.models import LockLevel
    from azure.mgmt.resource.managedapplications.models import ApplicationLockLevel

    from azure.cli.core.api import get_subscription_id_list
    from azure.cli.core.commands.parameters import (
        resource_group_name_type, get_location_type, tag_type, tags_type,
        get_resource_group_completion_list, no_wait_type, file_type,
        get_enum_type, get_three_state_flag)
    from azure.cli.core.profiles import ResourceType
    from azure.cli.core.local_context import LocalContextAttribute, STORE, ALL

    from knack.arguments import ignore_type, CLIArgumentType

    from azure.cli.command_modules.resource._completers import (
        get_policy_completion_list, get_policy_set_completion_list,
        get_policy_assignment_completion_list,
        get_resource_types_completion_list, get_providers_completion_list)
    from azure.cli.command_modules.resource._validators import (
        validate_lock_parameters, validate_resource_lock, validate_group_lock,
        validate_subscription_lock, validate_metadata, RollbackAction,
        validate_msi)

    # BASIC PARAMETER CONFIGURATION

    resource_name_type = CLIArgumentType(options_list=['--name', '-n'],
                                         help='The resource name. (Ex: myC)')
    resource_type_type = CLIArgumentType(
        help=
        "The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC')"
    )
    resource_namespace_type = CLIArgumentType(
        options_list='--namespace',
        completer=get_providers_completion_list,
        help="Provider namespace (Ex: 'Microsoft.Provider')")
    resource_parent_type = CLIArgumentType(
        required=False,
        options_list=['--parent'],
        help="The parent path (Ex: 'resA/myA/resB/myB')")
    existing_policy_definition_name_type = CLIArgumentType(
        options_list=['--name', '-n'],
        completer=get_policy_completion_list,
        help='The policy definition name.')
    existing_policy_set_definition_name_type = CLIArgumentType(
        options_list=['--name', '-n'],
        completer=get_policy_set_completion_list,
        help='The policy set definition name.')
    subscription_type = CLIArgumentType(
        options_list='--subscription',
        FilesCompleter=get_subscription_id_list,
        help='The subscription id of the policy [set] definition.')
    management_group_name_type = CLIArgumentType(
        options_list='--management-group',
        help='The name of the management group of the policy [set] definition.'
    )
    identity_scope_type = CLIArgumentType(
        help="Scope that the system assigned identity can access")
    identity_role_type = CLIArgumentType(
        options_list=['--role'],
        help="Role name or id that will be assigned to the managed identity")
    extended_json_format_type = CLIArgumentType(
        options_list=['--handle-extended-json-format', '-j'],
        action='store_true',
        is_preview=True,
        help=
        'Support to handle extended template content including multiline and comments in deployment'
    )
    deployment_name_type = CLIArgumentType(options_list=['--name', '-n'],
                                           required=True,
                                           help='The deployment name.')
    deployment_create_name_type = CLIArgumentType(
        options_list=['--name', '-n'],
        required=False,
        help='The deployment name. Default to template file base name')
    management_group_id_type = CLIArgumentType(
        options_list=['--management-group-id', '-m'],
        required=True,
        help='The management group id.')
    deployment_template_file_type = CLIArgumentType(
        options_list=['--template-file', '-f'],
        completer=FilesCompleter(),
        type=file_type,
        help="a template file path in the file system")
    deployment_template_uri_type = CLIArgumentType(
        options_list=['--template-uri', '-u'],
        help='a uri to a remote template file')
    deployment_parameters_type = CLIArgumentType(
        options_list=['--parameters', '-p'],
        action='append',
        nargs='+',
        completer=FilesCompleter(),
        help='the deployment parameters')
    filter_type = CLIArgumentType(
        options_list=['--filter'],
        is_preview=True,
        help=
        'Filter expression using OData notation. You can use --filter "provisioningState eq \'{state}\'" to filter provisioningState. '
        'To get more information, please visit https://docs.microsoft.com/en-us/rest/api/resources/deployments/listatsubscriptionscope#uri-parameters'
    )

    _PROVIDER_HELP_TEXT = 'the resource namespace, aka \'provider\''

    with self.argument_context('resource') as c:
        c.argument('no_wait', no_wait_type)
        c.argument('resource_group_name',
                   resource_group_name_type,
                   arg_group='Resource Id')
        c.ignore('resource_id')
        c.argument('resource_name',
                   resource_name_type,
                   arg_group='Resource Id')
        c.argument('api_version',
                   help='The api version of the resource (omit for latest)',
                   required=False,
                   arg_group='Resource Id')
        c.argument('resource_provider_namespace',
                   resource_namespace_type,
                   arg_group='Resource Id')
        c.argument('resource_type',
                   arg_type=resource_type_type,
                   completer=get_resource_types_completion_list,
                   arg_group='Resource Id')
        c.argument('parent_resource_path',
                   resource_parent_type,
                   arg_group='Resource Id')
        c.argument('tag', tag_type)
        c.argument('tags', tags_type)
        c.argument(
            'resource_ids',
            nargs='+',
            options_list=['--ids'],
            help=
            'One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.',
            arg_group='Resource Id')
        c.argument(
            'include_response_body',
            arg_type=get_three_state_flag(),
            help=
            'Use if the default command output doesn\'t capture all of the property data.'
        )

    with self.argument_context('resource list') as c:
        c.argument('name', resource_name_type)

    with self.argument_context('resource move') as c:
        c.argument('ids', nargs='+')

    with self.argument_context('resource invoke-action') as c:
        c.argument(
            'action',
            help='The action that will be invoked on the specified resource')
        c.argument(
            'request_body',
            help=
            'JSON encoded parameter arguments for the action that will be passed along in the post request body. Use @{file} to load from a file.'
        )

    with self.argument_context('resource create') as c:
        c.argument('resource_id',
                   options_list=['--id'],
                   help='Resource ID.',
                   action=None)
        c.argument(
            'properties',
            options_list=['--properties', '-p'],
            help='a JSON-formatted string containing resource properties')
        c.argument(
            'is_full_object',
            action='store_true',
            help=
            'Indicates that the properties object includes other options such as location, tags, sku, and/or plan.'
        )

    with self.argument_context('resource link') as c:
        c.argument(
            'target_id',
            options_list=[
                '--target',
                c.deprecate(target='--target-id',
                            redirect='--target',
                            hide=True)
            ],
            help='Fully-qualified resource ID of the resource link target.')
        c.argument('link_id',
                   options_list=[
                       '--link',
                       c.deprecate(target='--link-id',
                                   redirect='--link',
                                   hide=True)
                   ],
                   help='Fully-qualified resource ID of the resource link.')
        c.argument('notes', help='Notes for the link.')
        c.argument('scope', help='Fully-qualified scope for retrieving links.')
        c.argument('filter_string',
                   options_list=[
                       '--filter',
                       c.deprecate(target='--filter-string',
                                   redirect='--filter',
                                   hide=True)
                   ],
                   help='Filter string for limiting results.')

    with self.argument_context('provider') as c:
        c.ignore('top')
        c.argument('resource_provider_namespace',
                   options_list=['--namespace', '-n'],
                   completer=get_providers_completion_list,
                   help=_PROVIDER_HELP_TEXT)

    with self.argument_context('provider register') as c:
        c.argument('wait',
                   action='store_true',
                   help='wait for the registration to finish')

    with self.argument_context('provider unregister') as c:
        c.argument('wait',
                   action='store_true',
                   help='wait for unregistration to finish')

    with self.argument_context('provider operation') as c:
        c.argument(
            'api_version',
            help=
            "The api version of the 'Microsoft.Authorization/providerOperations' resource (omit for latest)"
        )

    with self.argument_context('feature') as c:
        c.argument('resource_provider_namespace',
                   options_list='--namespace',
                   required=True,
                   help=_PROVIDER_HELP_TEXT)
        c.argument('feature_name',
                   options_list=['--name', '-n'],
                   help='the feature name')

    with self.argument_context('feature list') as c:
        c.argument('resource_provider_namespace',
                   options_list='--namespace',
                   required=False,
                   help=_PROVIDER_HELP_TEXT)

    with self.argument_context('policy') as c:
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   help='the resource group where the policy will be applied')

    with self.argument_context(
            'policy definition',
            resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('policy_definition_name',
                   arg_type=existing_policy_definition_name_type)
        c.argument(
            'rules',
            help='JSON formatted string or a path to a file with such content',
            type=file_type,
            completer=FilesCompleter())
        c.argument('display_name', help='Display name of policy definition.')
        c.argument('description', help='Description of policy definition.')
        c.argument(
            'params',
            help=
            'JSON formatted string or a path to a file or uri with parameter definitions.',
            type=file_type,
            completer=FilesCompleter(),
            min_api='2016-12-01')
        c.argument('metadata',
                   min_api='2017-06-01-preview',
                   nargs='+',
                   validator=validate_metadata,
                   help='Metadata in space-separated key=value pairs.')
        c.argument('management_group', arg_type=management_group_name_type)
        c.argument(
            'mode',
            options_list=['--mode', '-m'],
            help=
            'Mode of the policy definition, e.g. All, Indexed. Please visit https://aka.ms/azure-policy-mode for more information.',
            min_api='2016-12-01')
        c.argument('subscription', arg_type=subscription_type)
        c.ignore('_subscription')  # disable global subscription

    with self.argument_context(
            'policy definition create',
            resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='Name of the new policy definition.')

    with self.argument_context(
            'policy assignment',
            resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.ignore('_subscription')
        c.argument('name',
                   options_list=['--name', '-n'],
                   completer=get_policy_assignment_completion_list,
                   help='Name of the policy assignment.')
        c.argument('scope',
                   help='Scope to which this policy assignment applies.')
        c.argument(
            'disable_scope_strict_match',
            action='store_true',
            help=
            'Include policy assignments either inherited from parent scope or at child scope.'
        )
        c.argument('display_name',
                   help='Display name of the policy assignment.')
        c.argument('policy',
                   help='Name or id of the policy definition.',
                   completer=get_policy_completion_list)

    with self.argument_context(
            'policy assignment create',
            resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='Name of the new policy assignment.')
        c.argument(
            'params',
            options_list=['--params', '-p'],
            help=
            'JSON formatted string or a path to a file or uri with parameter values of the policy rule.',
            type=file_type,
            completer=FilesCompleter(),
            min_api='2016-12-01')

    with self.argument_context('policy assignment create',
                               resource_type=ResourceType.MGMT_RESOURCE_POLICY,
                               min_api='2017-06-01-preview') as c:
        c.argument('policy_set_definition',
                   options_list=['--policy-set-definition', '-d'],
                   help='Name or id of the policy set definition.')
        c.argument('sku',
                   options_list=['--sku', '-s'],
                   help='policy sku.',
                   arg_type=get_enum_type(['free', 'standard']))
        c.argument('notscopes', options_list='--not-scopes', nargs='+')

    with self.argument_context('policy assignment create',
                               resource_type=ResourceType.MGMT_RESOURCE_POLICY,
                               min_api='2018-05-01') as c:
        c.argument(
            'location',
            arg_type=get_location_type(self.cli_ctx),
            help=
            'The location of the policy assignment. Only required when utilizing managed identity.'
        )

    with self.argument_context('policy assignment create',
                               resource_type=ResourceType.MGMT_RESOURCE_POLICY,
                               arg_group='Managed Identity',
                               min_api='2018-05-01') as c:
        c.argument(
            'assign_identity',
            nargs='*',
            validator=validate_msi,
            help="Assigns a system assigned identity to the policy assignment."
        )
        c.argument('identity_scope', arg_type=identity_scope_type)
        c.argument('identity_role', arg_type=identity_role_type)

    with self.argument_context('policy assignment create',
                               resource_type=ResourceType.MGMT_RESOURCE_POLICY,
                               min_api='2019-06-01') as c:
        c.argument(
            'enforcement_mode',
            options_list=['--enforcement-mode', '-e'],
            help=
            'Enforcement mode of the policy assignment, e.g. Default, DoNotEnforce. Please visit https://aka.ms/azure-policyAssignment-enforcement-mode for more information.',
            arg_type=get_enum_type(['Default', 'DoNotEnforce']))

    with self.argument_context('policy assignment identity',
                               resource_type=ResourceType.MGMT_RESOURCE_POLICY,
                               min_api='2018-05-01') as c:
        c.argument('identity_scope', arg_type=identity_scope_type)
        c.argument('identity_role', arg_type=identity_role_type)

    with self.argument_context(
            'policy set-definition',
            min_api='2017-06-01-preview',
            resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('policy_set_definition_name',
                   arg_type=existing_policy_set_definition_name_type)
        c.argument('display_name',
                   help='Display name of policy set definition.')
        c.argument('description', help='Description of policy set definition.')
        c.argument(
            'params',
            help=
            'JSON formatted string or a path to a file or uri with parameter definitions.',
            type=file_type,
            completer=FilesCompleter())
        c.argument(
            'definitions',
            help=
            'JSON formatted string or a path to a file or uri containing definitions.',
            type=file_type,
            completer=FilesCompleter())
        c.argument(
            'definition_groups',
            min_api='2019-09-01',
            help=
            'JSON formatted string or a path to a file or uri containing policy definition groups. Groups are used to organize policy definitions within a policy set.',
            type=file_type,
            completer=FilesCompleter())
        c.argument('metadata',
                   nargs='+',
                   validator=validate_metadata,
                   help='Metadata in space-separated key=value pairs.')
        c.argument('management_group', arg_type=management_group_name_type)
        c.argument('subscription', arg_type=subscription_type)
        c.ignore('_subscription')  # disable global subscription

    with self.argument_context(
            'policy set-definition create',
            min_api='2017-06-01-preview',
            resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='Name of the new policy set definition.')

    with self.argument_context('group') as c:
        c.argument('tag', tag_type)
        c.argument('tags', tags_type)
        c.argument('resource_group_name',
                   resource_group_name_type,
                   options_list=['--name', '-n', '--resource-group', '-g'])

    with self.argument_context('group deployment') as c:
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   completer=get_resource_group_completion_list)
        c.argument('deployment_name', arg_type=deployment_name_type)
        c.argument('template_file', arg_type=deployment_template_file_type)
        c.argument('template_uri', arg_type=deployment_template_uri_type)
        c.argument(
            'mode',
            arg_type=get_enum_type(DeploymentMode, default='incremental'),
            help=
            'Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)'
        )
        c.argument('parameters', arg_type=deployment_parameters_type)
        c.argument(
            'rollback_on_error',
            nargs='?',
            action=RollbackAction,
            help=
            'The name of a deployment to roll back to on error, or use as a flag to roll back to the last successful deployment.'
        )

    with self.argument_context('group deployment create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))
        c.argument(
            'aux_subscriptions',
            nargs='+',
            options_list=['--aux-subs'],
            help=
            'Auxiliary subscriptions which will be used during deployment across tenants.',
            deprecate_info=c.deprecate(target='--aux-subs',
                                       redirect='--aux-tenants'))
        c.argument(
            'aux_tenants',
            nargs='+',
            options_list=['--aux-tenants'],
            help=
            'Auxiliary tenants which will be used during deployment across tenants.'
        )

    with self.argument_context('group deployment validate') as c:
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('group deployment list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('group deployment operation show') as c:
        c.argument('operation_ids',
                   nargs='+',
                   help='A list of operation ids to show')

    with self.argument_context('deployment') as c:
        c.argument('deployment_name', arg_type=deployment_name_type)
        c.argument('deployment_location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=True)
        c.argument('template_file', arg_type=deployment_template_file_type)
        c.argument('template_uri', arg_type=deployment_template_uri_type)
        c.argument('parameters', arg_type=deployment_parameters_type)

    with self.argument_context('deployment create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment operation') as c:
        c.argument('operation_ids',
                   nargs='+',
                   help='A list of operation ids to show')

    with self.argument_context('deployment list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment sub') as c:
        c.argument('deployment_location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=True)

    with self.argument_context('deployment sub create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment sub validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment sub list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment group') as c:
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   completer=get_resource_group_completion_list,
                   required=True)
        c.argument(
            'mode',
            arg_type=get_enum_type(DeploymentMode, default='incremental'),
            help=
            'Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)'
        )
        c.argument(
            'rollback_on_error',
            nargs='?',
            action=RollbackAction,
            help=
            'The name of a deployment to roll back to on error, or use as a flag to roll back to the last successful deployment.'
        )

    with self.argument_context('deployment group create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))
        c.argument(
            'aux_subscriptions',
            nargs='+',
            options_list=['--aux-subs'],
            help=
            'Auxiliary subscriptions which will be used during deployment across tenants.',
            deprecate_info=c.deprecate(target='--aux-subs',
                                       redirect='--aux-tenants'))
        c.argument(
            'aux_tenants',
            nargs='+',
            options_list=['--aux-tenants'],
            help=
            'Auxiliary tenants which will be used during deployment across tenants.'
        )

    with self.argument_context('deployment group validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment group list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment mg') as c:
        c.argument('management_group_id', arg_type=management_group_id_type)
        c.argument('deployment_location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=True)

    with self.argument_context('deployment mg create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment mg validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment mg list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('deployment operation mg') as c:
        c.argument('management_group_id', arg_type=management_group_id_type)

    with self.argument_context('deployment tenant') as c:
        c.argument('deployment_location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=True)

    with self.argument_context('deployment tenant create') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment tenant validate') as c:
        c.argument('deployment_name', arg_type=deployment_create_name_type)
        c.argument('handle_extended_json_format',
                   arg_type=extended_json_format_type,
                   deprecate_info=c.deprecate(
                       target='--handle-extended-json-format/-j'))

    with self.argument_context('deployment tenant list') as c:
        c.argument('filter_string', arg_type=filter_type)

    with self.argument_context('group export') as c:
        c.argument('include_comments', action='store_true')
        c.argument('include_parameter_default_value', action='store_true')

    with self.argument_context('group create') as c:
        c.argument('rg_name',
                   options_list=['--name', '--resource-group', '-n', '-g'],
                   help='name of the new resource group',
                   completer=None,
                   local_context_attribute=LocalContextAttribute(
                       name='resource_group_name',
                       actions=[STORE],
                       scopes=[ALL]))
        c.argument(
            'managed_by',
            min_api='2016-09-01',
            help='The ID of the resource that manages this resource group.')

    with self.argument_context('tag') as c:
        c.argument('tag_name', options_list=['--name', '-n'])
        c.argument('tag_value', options_list='--value')

    with self.argument_context('lock') as c:
        c.argument('lock_name',
                   options_list=['--name', '-n'],
                   validator=validate_lock_parameters)
        c.argument('level',
                   arg_type=get_enum_type(LockLevel),
                   options_list=['--lock-type', '-t'],
                   help='The type of lock restriction.')
        c.argument('parent_resource_path', resource_parent_type)
        c.argument('resource_provider_namespace', resource_namespace_type)
        c.argument('resource_type',
                   arg_type=resource_type_type,
                   completer=get_resource_types_completion_list)
        c.argument(
            'resource_name',
            options_list=['--resource', '--resource-name'],
            help=
            'Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.'
        )
        c.argument(
            'ids',
            nargs='+',
            options_list='--ids',
            help=
            'One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.'
        )
        c.argument('resource_group',
                   resource_group_name_type,
                   validator=validate_lock_parameters)

    with self.argument_context('resource lock') as c:
        c.argument('resource_group', resource_group_name_type)
        c.argument(
            'resource_name',
            options_list=['--resource', '--resource-name'],
            help=
            'If an ID is given, other resource arguments should not be given.',
            validator=validate_resource_lock)

    with self.argument_context('group lock') as c:
        c.argument('resource_group',
                   resource_group_name_type,
                   validator=validate_group_lock,
                   id_part=None)

    with self.argument_context('group lock create') as c:
        c.argument('resource_group', required=True)

    with self.argument_context('account lock') as c:
        c.argument('resource_group',
                   ignore_type,
                   validator=validate_subscription_lock)

    for scope in ['account', 'group']:
        with self.argument_context('{} lock'.format(scope)) as c:
            c.ignore('resource_provider_namespace', 'parent_resource_path',
                     'resource_type', 'resource_name')

    for scope in ['lock', 'account lock', 'group lock', 'resource lock']:
        with self.argument_context(scope) as c:
            c.argument('lock_name',
                       options_list=['--name', '-n'],
                       help='Name of the lock')
            c.argument('level',
                       options_list=['--lock-type', '-t'],
                       arg_type=get_enum_type(
                           [LockLevel.can_not_delete, LockLevel.read_only]),
                       help='The type of lock restriction.')
            c.argument(
                'ids',
                nargs='+',
                options_list='--ids',
                help=
                'One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.'
            )
            c.argument('notes', help='Notes about this lock.')

    with self.argument_context('managedapp') as c:
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   help='the resource group of the managed application',
                   id_part='resource_group')
        c.argument('application_name',
                   options_list=['--name', '-n'],
                   id_part='name')

    with self.argument_context('managedapp definition') as c:
        c.argument(
            'resource_group_name',
            arg_type=resource_group_name_type,
            help='the resource group of the managed application definition',
            id_part='resource_group')
        c.argument('application_definition_name',
                   options_list=['--name', '-n'],
                   id_part='name')

    with self.argument_context('managedapp create') as c:
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='name of the new managed application',
                   completer=None)
        c.argument('location', help='the managed application location')
        c.argument('managedapp_definition_id',
                   options_list=['--managedapp-definition-id', '-d'],
                   help='the full qualified managed application definition id')
        c.argument(
            'managedby_resource_group_id',
            options_list=['--managed-rg-id', '-m'],
            help='the resource group managed by the managed application')
        c.argument(
            'parameters',
            help='JSON formatted string or a path to a file with such content',
            type=file_type)

    with self.argument_context('managedapp definition create') as c:
        c.argument('lock_level',
                   arg_type=get_enum_type(ApplicationLockLevel),
                   help='The type of lock restriction.')
        c.argument(
            'authorizations',
            options_list=['--authorizations', '-a'],
            nargs='+',
            help=
            "space-separated authorization pairs in a format of <principalId>:<roleDefinitionId>"
        )
        c.argument(
            'createUiDefinition',
            options_list=['--create-ui-definition', '-c'],
            help='JSON formatted string or a path to a file with such content',
            type=file_type)
        c.argument(
            'mainTemplate',
            options_list=['--main-template', '-t'],
            help='JSON formatted string or a path to a file with such content',
            type=file_type)

    with self.argument_context('account') as c:
        c.argument('subscription',
                   options_list=['--subscription', '-s'],
                   help='Name or ID of subscription.',
                   completer=get_subscription_id_list)
        c.ignore('_subscription')  # hide global subscription parameter

    with self.argument_context('account management-group') as c:
        c.argument('group_name', options_list=['--name', '-n'])

    with self.argument_context('account management-group show') as c:
        c.argument('expand',
                   options_list=['--expand', '-e'],
                   action='store_true')
        c.argument('recurse',
                   options_list=['--recurse', '-r'],
                   action='store_true')

    with self.argument_context('account management-group create') as c:
        c.argument('display_name', options_list=['--display-name', '-d'])
        c.argument('parent', options_list=['--parent', '-p'])

    with self.argument_context('account management-group update') as c:
        c.argument('display_name', options_list=['--display-name', '-d'])
        c.argument('parent_id', options_list=['--parent', '-p'])

    with self.argument_context('rest') as c:
        c.argument(
            'method',
            options_list=['--method', '-m'],
            arg_type=get_enum_type(
                ['head', 'get', 'put', 'post', 'delete', 'options', 'patch'],
                default='get'),
            help='HTTP request method')
        c.argument(
            'uri',
            options_list=['--uri', '-u'],
            help=
            'request uri. For uri without host, CLI will assume "https://management.azure.com/". '
            "Common token '{subscriptionId}' will be replaced with the current subscription ID specified by 'az account set'"
        )
        c.argument(
            'headers',
            nargs='+',
            help=
            "Space-separated headers in KEY=VALUE format or JSON string. Use @{file} to load from a file"
        )
        c.argument(
            'uri_parameters',
            nargs='+',
            help=
            'Space-separated queries in KEY=VALUE format or JSON string. Use @{file} to load from a file'
        )
        c.argument('skip_authorization_header',
                   action='store_true',
                   help='do not auto append "Authorization" header')
        c.argument('body',
                   options_list=['--body', '-b'],
                   help='request body. Use @{file} to load from a file')
        c.argument('output_file', help='save response payload to a file')
        c.argument(
            'resource',
            help=
            'Resource url for which CLI should acquire a token in order to access '
            'the service. The token will be placed in the "Authorization" header. By default, '
            'CLI can figure this out based on "--url" argument, unless you use ones not in the list '
            'of "az cloud show --query endpoints"')