示例#1
0
    def _complex_params(command_group):
        with self.argument_context('{} server create'.format(command_group)) as c:
            c.argument('sku_name', options_list=['--sku-name'], required=True, help='The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.')

            c.argument('backup_retention', type=int, options_list=['--backup-retention'], help='The number of days a backup is retained.')
            c.argument('geo_redundant_backup', options_list=['--geo-redundant-backup'], 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('administrator_login', required=True, arg_group='Authentication')
            c.argument('administrator_login_password', arg_group='Authentication')

            c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False)
            c.argument('version', help='Server 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, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.')

        with self.argument_context('{} server restore'. format(command_group)) as c:
            c.argument('source_server', options_list=['--source-server', '-s'], help='The name or ID of the source server to restore from.')
            c.argument('restore_point_in_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, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.')
            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 max days of retention, unit is days.')
            c.argument('geo_redundant_backup', options_list=['--geo-redundant-backup'], help='Enable Geo-redundant or not for server backup.')

        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')
示例#2
0
def load_arguments(self, _):
    with self.argument_context('container') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('name', options_list=['--name', '-n'], help="The name of the container group", id_part='name')
        c.argument('location', arg_type=get_location_type(self.cli_ctx))

    with self.argument_context('container create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('image', help='The container image name')
        c.argument('cpu', type=int, help='The required number of CPU cores of the containers')
        c.argument('memory', type=float, help='The required memory of the containers in GB')
        c.argument('os_type', arg_type=get_enum_type(OperatingSystemTypes), help='The OS type of the containers')
        c.argument('ip_address', arg_type=get_enum_type(IP_ADDRESS_TYPES), help='The IP address type of the container group')
        c.argument('ports', type=int, nargs='+', default=[80], help='The ports to open')
        c.argument('protocol', arg_type=get_enum_type(ContainerNetworkProtocol), help='The network protocol to use')
        c.argument('dns_name_label', help='The dns name label for container group with public IP')
        c.argument('restart_policy', arg_type=get_enum_type(ContainerGroupRestartPolicy), help='Restart policy for all containers within the container group')
        c.argument('command_line', help='The command line to run when the container is started, e.g. \'/bin/bash -c myscript.sh\'')
        c.argument('environment_variables', nargs='+', options_list=['--environment-variables', '-e'], type=_environment_variables_type, help='A list of environment variable for the container. Space-separated values in \'key=value\' format.')
        c.argument('secrets', secrets_type)
        c.argument('secrets_mount_path', validator=validate_volume_mount_path, help="The path within the container where the secrets volume should be mounted. Must not contain colon ':'.")
        c.argument('file', options_list=['--file', '-f'], help="The path to the input file.")

    with self.argument_context('container create', arg_group='Image Registry') as c:
        c.argument('registry_login_server', help='The container image registry login server')
        c.argument('registry_username', help='The username to log in container image registry server')
        c.argument('registry_password', help='The password to log in container image registry server')

    with self.argument_context('container create', arg_group='Azure File Volume') as c:
        c.argument('azure_file_volume_share_name', help='The name of the Azure File share to be mounted as a volume')
        c.argument('azure_file_volume_account_name', help='The name of the storage account that contains the Azure File share')
        c.argument('azure_file_volume_account_key', help='The storage account access key used to access the Azure File share')
        c.argument('azure_file_volume_mount_path', validator=validate_volume_mount_path, help="The path within the container where the azure file volume should be mounted. Must not contain colon ':'.")

    with self.argument_context('container create', arg_group='Log Analytics') as c:
        c.argument('log_analytics_workspace', help='The Log Analytics workspace name or id. If a name is specified, use the current subscription or use --subscription flag to set the desired subscription.')
        c.argument('log_analytics_workspace_key', help='The Log Analytics workspace key.')

    with self.argument_context('container create', arg_group='Git Repo Volume') as c:
        c.argument('gitrepo_url', help='The URL of a git repository to be mounted as a volume')
        c.argument('gitrepo_dir', validator=validate_gitrepo_directory, help="The target directory path in the git repository. Must not contain '..'.")
        c.argument('gitrepo_revision', help='The commit hash for the specified revision')
        c.argument('gitrepo_mount_path', validator=validate_volume_mount_path, help="The path within the container where the git repo volume should be mounted. Must not contain colon ':'.")

    with self.argument_context('container logs') as c:
        c.argument('container_name', help='The container name to tail the logs. If omitted, the first container in the container group will be chosen')
        c.argument('follow', help='Indicate to stream the tailing logs', action='store_true')

    with self.argument_context('container export') as c:
        c.argument('file', options_list=['--file', '-f'], help="The file path to export the container group.")

    with self.argument_context('container exec') as c:
        c.argument('container_name', help='The container name where to execute the command. Can be ommitted for container groups with only one container.')
        c.argument('exec_command', help='The command to run from within the container')
        c.argument('terminal_row_size', help='The row size for the command output')
        c.argument('terminal_col_size', help='The col size for the command output')

    with self.argument_context('container attach') as c:
        c.argument('container_name', help='The container to attach to. If omitted, the first container in the container group will be chosen')
def load_arguments(self, _):
    with self.argument_context('monitor app-insights') as c:
        c.argument('application', options_list=['--app', '-a'], id_part='name', help='GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.')

    with self.argument_context('monitor app-insights component create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('application-type', options_list=['application-type', '--type', '-t'], help="Type of application being monitored. Possible values include: 'web', 'other'. Default value: 'web' .")
        c.argument('kind', options_list=['--kind', '-k'], help='The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone.')
        c.argument('tags', tags_type)

    with self.argument_context('monitor app-insights component update') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('application-type', options_list=['application-type', '--type', '-t'], help="Type of application being monitored. Possible values include: 'web', 'other'. Default value: 'web' .")
        c.argument('kind', options_list=['--kind', '-k'], help='The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone.')

    with self.argument_context('monitor app-insights component update-tags') as c:
        c.argument('tags', tags_type)

    with self.argument_context('monitor app-insights api-key create') as c:
        c.argument('api_key', help='The name of the API key to create.')
        c.argument('read_properties', nargs='+', options_list=['--read-properties'])
        c.argument('write_properties', nargs='+')

    with self.argument_context('monitor app-insights api-key show') as c:
        c.argument('api_key', help='The name of the API key to fetch.')

    with self.argument_context('monitor app-insights metrics show') as c:
        c.argument('metric', options_list=['--metrics', '-m'], help='The metric to retrieve. May be either a standard AI metric or an application-specific custom metric.')
        c.argument('aggregation', nargs='*', help='The aggregation to use when computing the metric values. To retrieve more than one aggregation at a time, separate them with a comma. If no aggregation is specified, then the default aggregation for the metric is used.')
        c.argument('interval', arg_group='Time', type=get_period_type())
        c.argument('orderby', help='The aggregation function and direction to sort the segments by.  This value is only valid when segment is specified.')
        c.argument('segment', help='The name of the dimension to segment the metric values by. This dimension must be applicable to the metric you are retrieving. To segment by more than one dimension at a time, separate them with a comma (,). In this case, the metric data will be segmented in the order the dimensions are listed in the parameter.')
        c.argument('top', help='The number of segments to return.  This value is only valid when segment is specified.')
        c.argument('filter_arg', options_list=['--filter'], help=' An expression used to filter the results.  This value should be a valid OData filter expression where the keys of each clause should be applicable dimensions for the metric you are retrieving.')
        c.argument('start_time', arg_type=get_datetime_type(help='Start-time of time range for which to retrieve data.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End of time range for current operation. Defaults to the current time.'))
        c.argument('offset', help='Filter results based on UTC hour offset.', type=get_period_type(as_timedelta=True))

    with self.argument_context('monitor app-insights events show') as c:
        c.argument('event_type', options_list=['--type'], help='The type of events to retrieve.')
        c.argument('event', options_list=['--event'], help='GUID of the event to retrieve. This could be obtained by first listing and filtering events, then selecting an event of interest.')
        c.argument('start_time', arg_type=get_datetime_type(help='Start-time of time range for which to retrieve data.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End of time range for current operation. Defaults to the current time.'))
        c.argument('offset', help='Filter results based on UTC hour offset.', type=get_period_type(as_timedelta=True))

    with self.argument_context('monitor app-insights query') as c:
        c.argument('application', validator=validate_applications, options_list=['--apps', '-a'], nargs='+', id_part='name', help='GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.')
        c.argument('analytics_query', help='Query to execute over Application Insights data.')
        c.argument('start_time', arg_type=get_datetime_type(help='Start-time of time range for which to retrieve data.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End of time range for current operation. Defaults to the current time.'))
        c.argument('offset', help='Filter results based on UTC hour offset.', type=get_period_type(as_timedelta=True))
    def load_arguments(self, _):
        from azure.cli.core.commands.parameters import resource_group_name_type, get_location_type, deployment_name_type
        from azure.cli.core import ArgumentsContext

        from knack.arguments import ignore_type

        command_loaders = self.loaders

        if command_loaders:
            with ArgumentsContext(self, '') as c:
                c.argument('resource_group_name', resource_group_name_type)
                c.argument('location', get_location_type(self.cli_ctx))
                c.argument('deployment_name', deployment_name_type)
                c.argument('cmd', ignore_type)

            # load each command's arguments via reflection
            for _, command in self.command_table.items():
                command.load_arguments()

            for loader in command_loaders:
                loader.skip_applicability = True
                try:
                    loader.load_arguments(None)  # load each module's params file to the argument registry
                except (ValueError, ImportError) as ex:
                    logger.debug(ex)

                self.argument_registry.arguments.update(loader.argument_registry.arguments)
                self.extra_argument_registry.update(loader.extra_argument_registry)
                # _update_command_definitions needs these set
                self.cli_ctx.invocation.commands_loader.argument_registry = self.argument_registry
                self.cli_ctx.invocation.commands_loader.extra_argument_registry = self.extra_argument_registry
                loader._update_command_definitions()  # pylint: disable=protected-access
def load_arguments(self, _):
    with self.argument_context('spatial-anchors-account') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('spatial_anchors_account_name', arg_type=spatial_anchors_account_name_type)

    with self.argument_context('spatial-anchors-account create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)  # pylint: disable=line-too-long
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('spatial-anchors-account key renew') as c:
        c.argument('key', arg_type=spatial_anchors_account_key_type)
示例#6
0
    def _complex_params(command_group):
        with self.argument_context('{} server create'.format(command_group)) as c:
            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('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.')

        with self.argument_context('{} server restore'. format(command_group)) as c:
            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', 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('mysql server replica') as c:
            c.argument('source_server', options_list=['--source-server', '-s'], help='The name or resource ID of the master server to the create replica for.')

        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')
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.')
            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.ignore('server_name')
            c.ignore('resource_group_name')
            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.disabled.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('version', help='Server version', default='10')

    with self.argument_context('sql up') as c:
        c.argument('version', help='Server version', default='12.0')
示例#8
0
def load_arguments(self, _):

    with self.argument_context('iotcentral app') as c:
        c.argument('app_name',
                   app_name_type,
                   options_list=['--name', '-n'],
                   id_part='display_name')

    with self.argument_context('iotcentral app create') as c:
        c.argument('app_name', completer=None)
        c.argument('location', get_location_type(self.cli_ctx),
                   help='Location of your IoT Central application. Default is the location of target resource group.')
        c.argument('sku', arg_type=get_enum_type(AppSku),
                   help='Pricing tier for IoT Central applications. Default value is F1, which is free.')
        c.argument(
            'subdomain', help='Subdomain for the IoT Central URL. Each application must have a unique subdomain.')
示例#9
0
def load_arguments(self, _):
    with self.argument_context('signalr') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('signalr_name', options_list=['--name', '-n'],
                   completer=get_resource_name_completion_list(SIGNALR_RESOURCE_TYPE),
                   help='Name of signalr service.')
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('signalr create') as c:
        c.argument('sku', help='The sku name of the signalr service. E.g. Standard_S1')
        c.argument('unit_count', help='The number of signalr service unit count', type=int)

    with self.argument_context('signalr key renew') as c:
        c.argument('key_type', help='The name of access key to regenerate', choices=SIGNALR_KEY_TYPE)
示例#10
0
def load_arguments(self, _):
    with self.argument_context('cognitiveservices') as c:
        c.argument('account_name', arg_type=name_arg_type, help='cognitive service account name',
                   completer=get_resource_name_completion_list('Microsoft.CognitiveServices/accounts'))
        c.argument('location', arg_type=get_location_type(self.cli_ctx),
                   completer=location_completer)
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('sku_name', options_list=['--sku'], help='the Sku of cognitive services account',
                   completer=sku_name_completer)
        c.argument('kind', help='the API name of cognitive services account',
                   completer=kind_completer)
        c.argument('tags', tags_type)
        c.argument('key_name', required=True, help='Key name to generate', choices=['key1', 'key2'])
        c.argument('api_properties', api_properties_type)

    with self.argument_context('cognitiveservices account create') as c:
        c.argument('yes', action='store_true', help='Do not prompt for terms confirmation')
示例#11
0
    def load_arguments(self, command):
        from azure.cli.core.commands.parameters import resource_group_name_type, get_location_type, deployment_name_type
        from knack.arguments import ignore_type

        command_loaders = self.cmd_to_loader_map.get(command, None)

        if command_loaders:
            for loader in command_loaders:
                # register global args
                with loader.argument_context('') as c:
                    c.argument('resource_group_name', resource_group_name_type)
                    c.argument('location', get_location_type(self.cli_ctx))
                    c.argument('deployment_name', deployment_name_type)
                    c.argument('cmd', ignore_type)

                loader.command_name = command
                self.command_table[command].load_arguments()  # this loads the arguments via reflection
                loader.load_arguments(command)  # this adds entries to the argument registries
                self.argument_registry.arguments.update(loader.argument_registry.arguments)
                self.extra_argument_registry.update(loader.extra_argument_registry)
                loader._update_command_definitions()  # pylint: disable=protected-access
示例#12
0
def load_arguments(self, _):
    with self.argument_context('eventgrid') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('tags', arg_type=tags_type)
        c.argument('included_event_types', arg_type=included_event_types_type)
        c.argument('labels', arg_type=labels_type)
        c.argument('endpoint_type', arg_type=get_enum_type(['webhook', 'eventhub'], default='webhook'))
        c.argument('resource_id', help="Fully qualified identifier of the Azure resource.")
        c.argument('endpoint', help="Endpoint where EventGrid should deliver events matching this event subscription. For webhook endpoint type, this should be the corresponding webhook URL. For eventhub endpoint type, this should be the Azure ResourceID of the event hub.")
        c.argument('event_subscription_name', help="Name of the event subscription.")
        c.argument('subject_begins_with', help="An optional string to filter events for an event subscription based on a prefix. Wildcard characters are not supported.")
        c.argument('subject_ends_with', help="An optional string to filter events for an event subscription based on a suffix. Wildcard characters are not supported.")
        c.argument('topic_type_name', help="Name of the topic type.")
        c.argument('is_subject_case_sensitive', arg_type=get_three_state_flag(), options_list=['--subject-case-sensitive'], help="Specify to indicate whether the subject fields should be compared in a case sensitive manner. True if flag present.", )

    with self.argument_context('eventgrid topic') as c:
        c.argument('topic_name', arg_type=name_type, help='Name of the topic', id_part='name', completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))

    with self.argument_context('eventgrid event-subscription') as c:
        c.argument('topic_name', help='Name of the Event Grid topic', options_list=['--topic-name'], completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))
        c.argument('event_subscription_name', arg_type=name_type, help='Name of the event subscription')

    with self.argument_context('eventgrid event-subscription create') as c:
        c.argument('topic_name', help='Name of the Event Grid topic to which the event subscription needs to be created.', options_list=['--topic-name'], completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))
        c.argument('event_subscription_name', arg_type=name_type, help='Name of the new event subscription')
        c.argument('resource_id', help="Fully qualified identifier of the Azure resource to which the event subscription needs to be created.")

    with self.argument_context('eventgrid event-subscription delete') as c:
        c.argument('topic_name', help='Name of the Event Grid topic whose event subscription needs to be deleted.', options_list=['--topic-name'], completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))
        c.argument('event_subscription_name', arg_type=name_type, help='Name of the event subscription')
        c.argument('resource_id', help="Fully qualified identifier of the Azure resource whose event subscription needs to be deleted.")

    with self.argument_context('eventgrid event-subscription show') as c:
        c.argument('include_full_endpoint_url', arg_type=get_three_state_flag(), options_list=['--include-full-endpoint-url'], help="Specify to indicate whether the full endpoint URL should be returned. True if flag present.", )

    with self.argument_context('eventgrid topic-type') as c:
        c.argument('topic_type_name', arg_type=name_type, help="Name of the topic type.", completer=get_resource_name_completion_list('Microsoft.EventGrid/topictypes'))
示例#13
0
def load_arguments(self, _):

    with self.argument_context('stack-hci arc-setting list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the cluster.')

    with self.argument_context('stack-hci arc-setting show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.',
            id_part='child_name_1')

    with self.argument_context('stack-hci arc-setting create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the cluster.')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.'
        )
        c.argument(
            'arc_instance_resource_group',
            options_list=['--instance-rg'],
            type=str,
            help='The resource group '
            'that hosts the Arc agents, ie. Hybrid Compute Machine resources.')
        c.argument('arc_application_client_id',
                   type=str,
                   help='App id of arc AAD identity.')
        c.argument('arc_application_tenant_id',
                   type=str,
                   help='Tenant id of arc AAD identity.')
        c.argument('arc_service_principal_object_id',
                   type=str,
                   help='Object id of arc AAD service principal.')
        c.argument('arc_application_object_id',
                   type=str,
                   help='Object id of arc AAD identity.')
        c.argument(
            'connectivity_properties',
            type=validate_file_or_dict,
            help='contains connectivity related '
            'configuration for ARC resources Expected value: json-string/json-file/@json-file.'
        )
        c.argument('created_by',
                   type=str,
                   help='The identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_by_type',
                   arg_type=get_enum_type(
                       ['User', 'Application', 'ManagedIdentity', 'Key']),
                   help='The type of identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_at',
                   help='The timestamp of resource creation (UTC).',
                   arg_group='System Data')
        c.argument('last_modified_by',
                   type=str,
                   help='The identity that last modified the resource.',
                   arg_group='System Data')
        c.argument(
            'last_modified_by_type',
            arg_type=get_enum_type(
                ['User', 'Application', 'ManagedIdentity', 'Key']),
            help='The type of identity that last modified the resource.',
            arg_group='System Data')
        c.argument('last_modified_at',
                   help='The timestamp of resource last modification (UTC)',
                   arg_group='System '
                   'Data')

    with self.argument_context('stack-hci arc-setting update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.',
            id_part='child_name_1')
        c.argument('tags', tags_type)
        c.argument(
            'connectivity_properties',
            type=validate_file_or_dict,
            help='contains connectivity related '
            'configuration for ARC resources Expected value: json-string/json-file/@json-file.'
        )

    with self.argument_context('stack-hci arc-setting delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.',
            id_part='child_name_1')

    with self.argument_context('stack-hci arc-setting create-identity') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the cluster.')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.'
        )

    with self.argument_context('stack-hci arc-setting generate-password') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.',
            id_part='child_name_1')

    with self.argument_context('stack-hci arc-setting wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            options_list=['--name', '-n', '--arc-setting-name'],
            type=str,
            help='The name '
            'of the proxy resource holding details of HCI ArcSetting information.',
            id_part='child_name_1')

    with self.argument_context('stack-hci cluster list') as c:
        c.argument('resource_group_name', resource_group_name_type)

    with self.argument_context('stack-hci cluster show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   options_list=['--name', '-n', '--cluster-name'],
                   type=str,
                   help='The name of the '
                   'cluster.',
                   id_part='name')

    with self.argument_context('stack-hci cluster create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   options_list=['--name', '-n', '--cluster-name'],
                   type=str,
                   help='The name of the '
                   'cluster.')
        c.argument('tags', tags_type)
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('cloud_management_endpoint',
                   options_list=['--endpoint'],
                   type=str,
                   help='Endpoint configured for '
                   'management from the Azure portal.')
        c.argument('aad_client_id',
                   type=str,
                   help='App id of cluster AAD identity.')
        c.argument('aad_tenant_id',
                   type=str,
                   help='Tenant id of cluster AAD identity.')
        c.argument('aad_application_object_id',
                   type=str,
                   help='Object id of cluster AAD identity.')
        c.argument('aad_service_principal_object_id',
                   type=str,
                   help='Id of cluster identity service principal.')
        c.argument('desired_properties',
                   action=AddDesiredProperties,
                   nargs='+',
                   help='Desired properties of the '
                   'cluster.')
        c.argument('created_by',
                   type=str,
                   help='The identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_by_type',
                   arg_type=get_enum_type(
                       ['User', 'Application', 'ManagedIdentity', 'Key']),
                   help='The type of identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_at',
                   help='The timestamp of resource creation (UTC).',
                   arg_group='System Data')
        c.argument('last_modified_by',
                   type=str,
                   help='The identity that last modified the resource.',
                   arg_group='System Data')
        c.argument(
            'last_modified_by_type',
            arg_type=get_enum_type(
                ['User', 'Application', 'ManagedIdentity', 'Key']),
            help='The type of identity that last modified the resource.',
            arg_group='System Data')
        c.argument('last_modified_at',
                   help='The timestamp of resource last modification (UTC)',
                   arg_group='System '
                   'Data')

    with self.argument_context('stack-hci cluster update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   options_list=['--name', '-n', '--cluster-name'],
                   type=str,
                   help='The name of the '
                   'cluster.',
                   id_part='name')
        c.argument('tags', tags_type)
        c.argument('cloud_management_endpoint',
                   options_list=['--endpoint'],
                   type=str,
                   help='Endpoint configured for '
                   'management from the Azure portal')
        c.argument('aad_client_id',
                   type=str,
                   help='App id of cluster AAD identity.')
        c.argument('aad_tenant_id',
                   type=str,
                   help='Tenant id of cluster AAD identity.')
        c.argument('desired_properties',
                   action=AddDesiredProperties,
                   nargs='+',
                   help='Desired properties of the '
                   'cluster.')

    with self.argument_context('stack-hci cluster delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   options_list=['--name', '-n', '--cluster-name'],
                   type=str,
                   help='The name of the '
                   'cluster.',
                   id_part='name')

    with self.argument_context('stack-hci cluster create-identity') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   options_list=['--name', '-n', '--cluster-name'],
                   type=str,
                   help='The name of the '
                   'cluster.')

    with self.argument_context('stack-hci cluster wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   options_list=['--name', '-n', '--cluster-name'],
                   type=str,
                   help='The name of the '
                   'cluster.',
                   id_part='name')

    with self.argument_context('stack-hci extension list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the cluster.')
        c.argument(
            'arc_setting_name',
            type=str,
            help='The name of the proxy resource holding details of HCI '
            'ArcSetting information.')

    with self.argument_context('stack-hci extension show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            type=str,
            help='The name of the proxy resource holding details of HCI '
            'ArcSetting information.',
            id_part='child_name_1')
        c.argument('extension_name',
                   options_list=['--name', '-n', '--extension-name'],
                   type=str,
                   help='The name of '
                   'the machine extension.',
                   id_part='child_name_2')

    with self.argument_context('stack-hci extension create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the cluster.')
        c.argument(
            'arc_setting_name',
            type=str,
            help='The name of the proxy resource holding details of HCI '
            'ArcSetting information.')
        c.argument('extension_name',
                   options_list=['--name', '-n', '--extension-name'],
                   type=str,
                   help='The name of '
                   'the machine extension.')
        c.argument(
            'force_update_tag',
            type=str,
            help='How the extension handler should be forced to update even if '
            'the extension configuration has not changed.',
            arg_group='Extension Parameters')
        c.argument('publisher',
                   type=str,
                   help='The name of the extension handler publisher.',
                   arg_group='Extension '
                   'Parameters')
        c.argument(
            'type_properties_extension_parameters_type',
            options_list=['--type'],
            type=str,
            help='Specifies the '
            'type of the extension; an example is "CustomScriptExtension".',
            arg_group='Extension Parameters')
        c.argument('type_handler_version',
                   type=str,
                   help='Specifies the version of the script handler.',
                   arg_group='Extension Parameters')
        c.argument(
            'auto_upgrade_minor_version',
            options_list=['--auto-upgrade'],
            arg_type=get_three_state_flag(),
            help=
            'Indicates whether the extension should use a newer minor version if one is available at '
            'deployment time. Once deployed, however, the extension will not upgrade minor versions unless '
            'redeployed, even with this property set to true.',
            arg_group='Extension Parameters')
        c.argument('settings',
                   type=validate_file_or_dict,
                   help='Json formatted public settings for the extension. '
                   'Expected value: json-string/json-file/@json-file.',
                   arg_group='Extension Parameters')
        c.argument('protected_settings',
                   type=validate_file_or_dict,
                   help='Protected settings (may contain secrets). '
                   'Expected value: json-string/json-file/@json-file.',
                   arg_group='Extension Parameters')
        c.argument('created_by',
                   type=str,
                   help='The identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_by_type',
                   arg_type=get_enum_type(
                       ['User', 'Application', 'ManagedIdentity', 'Key']),
                   help='The type of identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_at',
                   help='The timestamp of resource creation (UTC).',
                   arg_group='System Data')
        c.argument('last_modified_by',
                   type=str,
                   help='The identity that last modified the resource.',
                   arg_group='System Data')
        c.argument(
            'last_modified_by_type',
            arg_type=get_enum_type(
                ['User', 'Application', 'ManagedIdentity', 'Key']),
            help='The type of identity that last modified the resource.',
            arg_group='System Data')
        c.argument('last_modified_at',
                   help='The timestamp of resource last modification (UTC)',
                   arg_group='System '
                   'Data')

    with self.argument_context('stack-hci extension update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            type=str,
            help='The name of the proxy resource holding details of HCI '
            'ArcSetting information.',
            id_part='child_name_1')
        c.argument('extension_name',
                   options_list=['--name', '-n', '--extension-name'],
                   type=str,
                   help='The name of '
                   'the machine extension.',
                   id_part='child_name_2')
        c.argument(
            'force_update_tag',
            type=str,
            help='How the extension handler should be forced to update even if '
            'the extension configuration has not changed.',
            arg_group='Extension Parameters')
        c.argument('publisher',
                   type=str,
                   help='The name of the extension handler publisher.',
                   arg_group='Extension '
                   'Parameters')
        c.argument(
            'type_properties_extension_parameters_type',
            options_list=['--type'],
            type=str,
            help='Specifies the '
            'type of the extension; an example is "CustomScriptExtension".',
            arg_group='Extension Parameters')
        c.argument('type_handler_version',
                   type=str,
                   help='Specifies the version of the script handler.',
                   arg_group='Extension Parameters')
        c.argument(
            'auto_upgrade_minor_version',
            options_list=['--auto-upgrade'],
            arg_type=get_three_state_flag(),
            help=
            'Indicates whether the extension should use a newer minor version if one is available at '
            'deployment time. Once deployed, however, the extension will not upgrade minor versions unless '
            'redeployed, even with this property set to true.',
            arg_group='Extension Parameters')
        c.argument('settings',
                   type=validate_file_or_dict,
                   help='Json formatted public settings for the extension. '
                   'Expected value: json-string/json-file/@json-file.',
                   arg_group='Extension Parameters')
        c.argument('protected_settings',
                   type=validate_file_or_dict,
                   help='Protected settings (may contain secrets). '
                   'Expected value: json-string/json-file/@json-file.',
                   arg_group='Extension Parameters')
        c.argument('created_by',
                   type=str,
                   help='The identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_by_type',
                   arg_type=get_enum_type(
                       ['User', 'Application', 'ManagedIdentity', 'Key']),
                   help='The type of identity that created the resource.',
                   arg_group='System Data')
        c.argument('created_at',
                   help='The timestamp of resource creation (UTC).',
                   arg_group='System Data')
        c.argument('last_modified_by',
                   type=str,
                   help='The identity that last modified the resource.',
                   arg_group='System Data')
        c.argument(
            'last_modified_by_type',
            arg_type=get_enum_type(
                ['User', 'Application', 'ManagedIdentity', 'Key']),
            help='The type of identity that last modified the resource.',
            arg_group='System Data')
        c.argument('last_modified_at',
                   help='The timestamp of resource last modification (UTC)',
                   arg_group='System '
                   'Data')

    with self.argument_context('stack-hci extension delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            type=str,
            help='The name of the proxy resource holding details of HCI '
            'ArcSetting information.',
            id_part='child_name_1')
        c.argument('extension_name',
                   options_list=['--name', '-n', '--extension-name'],
                   type=str,
                   help='The name of '
                   'the machine extension.',
                   id_part='child_name_2')

    with self.argument_context('stack-hci extension wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name',
                   type=str,
                   help='The name of the cluster.',
                   id_part='name')
        c.argument(
            'arc_setting_name',
            type=str,
            help='The name of the proxy resource holding details of HCI '
            'ArcSetting information.',
            id_part='child_name_1')
        c.argument('extension_name',
                   options_list=['--name', '-n', '--extension-name'],
                   type=str,
                   help='The name of '
                   'the machine extension.',
                   id_part='child_name_2')
示例#14
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_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'))
    container_name_type = CLIArgumentType(
        options_list=['--container-name', '-c'],
        help='The container name.',
        completer=get_container_name_completions)
    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'))

    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', 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')

    for item in [
            'delete', 'show', 'update', 'show-connection-string', 'keys',
            '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 check-name') as c:
        c.argument('name', options_list=['--name', '-n'])

    with self.argument_context('storage account create') as c:
        t_account_type, t_sku_name, t_kind = self.get_models(
            'AccountType',
            'SkuName',
            'Kind',
            resource_type=CUSTOM_MGMT_STORAGE)
        c.register_common_storage_account_options()
        c.argument(
            'hierarchical_namespace',
            help='Allows the blob service to exhibit filesystem semantics.',
            arg_type=get_three_state_flag())
        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)
        c.argument('kind',
                   help='Indicates the type of storage account.',
                   arg_type=get_enum_type(t_kind, default='storage'))
        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'))

    with self.argument_context('storage account update') as c:
        c.register_common_storage_account_options()
        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)

    with self.argument_context('storage account update',
                               arg_group='Customer managed key',
                               min_api='2017-06-01') as c:
        c.extra(
            'encryption_key_name',
            help='The name of the KeyVault key',
        )
        c.extra('encryption_key_vault', help='The Uri of the KeyVault')
        c.extra('encryption_key_version',
                help='The version of the KeyVault key')
        c.argument(
            'encryption_key_source',
            arg_type=get_enum_type(['Microsoft.Storage', 'Microsoft.Keyvault'],
                                   'Microsoft.Storage'),
            help='The default encryption service',
            validator=validate_encryption_source)
        c.ignore('encryption_key_vault_properties')

    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.')

    with self.argument_context('storage account show-connection-string') as c:
        c.argument('protocol',
                   help='The default endpoint protocol.',
                   arg_type=get_enum_type(['http', 'https']))
        c.argument('key_name',
                   options_list=['--key'],
                   help='The key to use.',
                   arg_type=get_enum_type(
                       list(storage_account_key_options.keys())))
        for item in ['blob', 'file', 'queue', 'table']:
            c.argument('{}_endpoint'.format(item),
                       help='Custom endpoint for {}s.'.format(item))

    with self.argument_context('storage account keys renew') as c:
        c.argument('key_name',
                   options_list=['--key'],
                   help='The key to regenerate.',
                   validator=validate_key,
                   arg_type=get_enum_type(
                       list(storage_account_key_options.keys())))
        c.argument('account_name', acct_name_type, id_part=None)

    with self.argument_context('storage account keys list') as c:
        c.argument('account_name', acct_name_type, id_part=None)

    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.')

    with self.argument_context(
            'storage account management-policy create') as c:
        c.argument(
            'policy',
            type=file_type,
            completer=FilesCompleter(),
            help=
            'The Storage Account ManagementPolicies Rules, in JSON format. See more details in: '
            'https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.'
        )
        c.argument(
            'account_name',
            help=
            'The name of the storage account within the specified resource group.'
        )

    with self.argument_context(
            'storage account management-policy update') as c:
        c.argument(
            'account_name',
            help=
            'The name of the storage account within the specified resource group.'
        )

    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.'
        )
示例#15
0
def load_arguments_eh(self, _):
    from azure.cli.core.commands.parameters import tags_type, get_enum_type, resource_group_name_type, name_type, \
        get_location_type, get_three_state_flag, get_resource_name_completion_list
    from azure.cli.core.commands.validators import get_default_location_from_resource_group
    from azure.cli.command_modules.eventhubs._completers import get_consumergroup_command_completion_list, \
        get_eventhubs_command_completion_list
    from azure.cli.command_modules.eventhubs._validator import validate_storageaccount, validate_partner_namespace, validate_rights
    from knack.arguments import CLIArgumentType
    from azure.cli.core.profiles import ResourceType
    (KeyType, AccessRights, SkuName, KeySource) = self.get_models('KeyType', 'AccessRights', 'SkuName', 'KeySource', resource_type=ResourceType.MGMT_EVENTHUB)
    from azure.cli.command_modules.eventhubs.action import AlertAddEncryption

    rights_arg_type = CLIArgumentType(options_list=['--rights'], nargs='+', arg_type=get_enum_type(AccessRights), validator=validate_rights, help='Space-separated list of Authorization rule rights')
    key_arg_type = CLIArgumentType(options_list=['--key'], arg_type=get_enum_type(KeyType), help='specifies Primary or Secondary key needs to be reset')
    keyvalue_arg_type = CLIArgumentType(options_list=['--key-value'], help='Optional, if the key value provided, is set for KeyType or autogenerated Key value set for keyType.')
    event_hub_name_arg_type = CLIArgumentType(options_list=['--eventhub-name'], help='Name of EventHub')
    namespace_name_arg_type = CLIArgumentType(options_list=['--namespace-name'], help='Name of Namespace', id_part='name')

    with self.argument_context('eventhubs') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('namespace_name', id_part='name', help='name of Namespace')

    with self.argument_context('eventhubs namespace exists') as c:
        c.argument('name', arg_type=name_type, help='Namespace name. Name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number.')

    with self.argument_context('eventhubs namespace', min_api='2021-06-01-preview') as c:
        c.argument('namespace_name', arg_type=name_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.ServiceBus/namespaces'), help='Name of Namespace')
        c.argument('is_kafka_enabled', options_list=['--enable-kafka'], arg_type=get_three_state_flag(),
                   help='A boolean value that indicates whether Kafka is enabled for eventhub namespace.')
        c.argument('tags', arg_type=tags_type)
        c.argument('sku', options_list=['--sku'], arg_type=get_enum_type(SkuName), help='Namespace SKU.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('capacity', type=int, help='Capacity for Sku')
        c.argument('is_auto_inflate_enabled', options_list=['--enable-auto-inflate'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether AutoInflate is enabled for eventhub namespace.')
        c.argument('maximum_throughput_units', type=int, help='Upper limit of throughput units when AutoInflate is enabled, vaule should be within 0 to 20 throughput units. ( 0 if AutoInflateEnabled = true)')
        c.argument('default_action', arg_group='networkrule', options_list=['--default-action'], arg_type=get_enum_type(['Allow', 'Deny']),
                   help='Default Action for Network Rule Set.')
        c.argument('trusted_service_access_enabled', options_list=['--enable-trusted-service-access', '-t'], arg_type=get_three_state_flag(),
                   help='A boolean value that indicates whether Trusted Service Access is enabled for Network Rule Set.')
        c.argument('zone_redundant', options_list=['--zone-redundant'], is_preview=True, arg_type=get_three_state_flag(),
                   help='Enabling this property creates a Standard EventHubs Namespace in regions supported availability zones')
        c.argument('identity', arg_group='Managed Identity', options_list=['--assign-identity'], is_preview=True, arg_type=get_three_state_flag(),
                   help='A boolean value that indicates whether Managed Identity is enabled.')
        c.argument('disable_local_auth', options_list=['--disable-local-auth'], is_preview=True, arg_type=get_three_state_flag(),
                   help='A boolean value that indicates whether SAS authentication is enabled/disabled for the Event Hubs')
        c.argument('mi_system_assigned', arg_group='Managed Identity',
                   arg_type=get_three_state_flag(),
                   help='Enable System Assigned Identity')
        c.argument('mi_user_assigned', arg_group='Managed Identity', nargs='+', help='List of User Assigned Identity ids.')
        c.argument('encryption_config', action=AlertAddEncryption, nargs='+', help='List of KeyVaultProperties objects.')

    with self.argument_context('eventhubs namespace create', min_api='2021-06-01-preview') as c:
        c.argument('cluster_arm_id', options_list=['--cluster-arm-id'], is_preview=True, help='Cluster ARM ID of the Namespace')

    with self.argument_context('eventhubs namespace update', arg_group='Managed Identity', min_api='2021-06-01-preview') as c:
        c.argument('key_source', options_list=['--key-source'], is_preview=True, arg_type=get_enum_type(KeySource),
                   help='Encryption key source. Possible values include: \'Microsoft.KeyVault\'.')
        c.argument('key_name', is_preview=True, help='The name of the KeyVault key.', )
        c.argument('key_vault_uri', is_preview=True, help='The Uri of the KeyVault.')
        c.argument('key_version', is_preview=True,
                   help='The version of the KeyVault key to use.')
        c.argument('require_infrastructure_encryption', options_list=['--infra-encryption'], is_preview=True,
                   arg_type=get_three_state_flag(),
                   help='A boolean value that indicates whether Infrastructure Encryption (Double Encryption) is enabled/disabled')

# Cluster region
    for scope in ['eventhubs cluster', 'eventhubs cluster namespace list']:
        with self.argument_context(scope) as c:
            c.argument('cluster_name', arg_type=name_type, id_part=None, help='Name of Cluster')

    with self.argument_context('eventhubs cluster create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part=None, help='Location of the Cluster, for locations of available pre-provision clusters, please check az evetnhubs ')
        c.argument('capacity', type=int, help='Capacity for Sku, allowed value : 1')

    for scope in ['eventhubs cluster create', 'eventhubs cluster update']:
        with self.argument_context(scope) as c:
            c.argument('tags', arg_type=tags_type)

    # region Namespace Authorizationrule
    with self.argument_context('eventhubs namespace authorization-rule list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs namespace authorization-rule keys list') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='Name of Namespace AuthorizationRule')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    for scope in ['eventhubs namespace authorization-rule', 'eventhubs namespace authorization-rule keys renew']:
        with self.argument_context(scope) as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_1', help='Name of Namespace AuthorizationRule')
            c.argument('namespace_name', arg_type=namespace_name_arg_type, help='Name of Namespace')

    for scope in ['eventhubs namespace authorization-rule create', 'eventhubs namespace authorization-rule update', 'eventhubs eventhub authorization-rule create', 'eventhubs eventhub authorization-rule update']:
        with self.argument_context(scope) as c:
            c.argument('name', arg_type=name_type, help='Name of Authorization Rule')
            c.argument('rights', arg_type=rights_arg_type)

    with self.argument_context('eventhubs namespace authorization-rule keys renew') as c:
        c.argument('name', arg_type=name_type, help='Name of Authorization Rule')
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)

# region - Eventhub Create
    with self.argument_context('eventhubs eventhub') as c:
        c.argument('event_hub_name', arg_type=name_type, id_part='child_name_1', completer=get_eventhubs_command_completion_list, help='Name of Eventhub')

    for scope in ['eventhubs eventhub update', 'eventhubs eventhub create']:
        with self.argument_context(scope) as c:
            c.argument('message_retention_in_days', options_list=['--message-retention'], type=int, help='Number of days to retain events for this Event Hub, value should be 1 to 7 days and depends on Namespace sku. if Namespace sku is Basic than value should be one and is Manadatory parameter. Namespace sku is standard value should be 1 to 7 days, default is 7 days and is optional parameter')
            c.argument('partition_count', type=int, help='Number of partitions created for the Event Hub. By default, allowed values are 2-32. Lower value of 1 is supported with Kafka enabled namespaces. In presence of a custom quota, the upper limit will match the upper limit of the quota.')
            c.argument('status', arg_type=get_enum_type(['Active', 'Disabled', 'SendDisabled']), help='Status of Eventhub')
            c.argument('enabled', options_list=['--enable-capture'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether capture is enabled.')
            c.argument('skip_empty_archives', options_list=['--skip-empty-archives'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether to Skip Empty.')
            c.argument('capture_interval_seconds', arg_group='Capture', options_list=['--capture-interval'], type=int, help='Allows you to set the frequency with which the capture to Azure Blobs will happen, value should between 60 to 900 seconds')
            c.argument('capture_size_limit_bytes', arg_group='Capture', options_list=['--capture-size-limit'], type=int, help='Defines the amount of data built up in your Event Hub before an capture operation, value should be between 10485760 to 524288000 bytes')
            c.argument('destination_name', arg_group='Capture-Destination', help='Name for capture destination, should be EventHubArchive.AzureBlockBlob.')
            c.argument('storage_account_resource_id', arg_group='Capture-Destination', validator=validate_storageaccount, options_list=['--storage-account'], help='Name (if within same resource group and not of type Classic Storage) or ARM id of the storage account to be used to create the blobs')
            c.argument('blob_container', arg_group='Capture-Destination', help='Blob container Name')
            c.argument('archive_name_format', arg_group='Capture-Destination', help='Blob naming convention for archive, e.g. {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order')

    with self.argument_context('eventhubs eventhub list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    # region EventHub Authorizationrule
    for scope in ['eventhubs eventhub authorization-rule']:
        with self.argument_context(scope) as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='Name of EventHub AuthorizationRule')
            c.argument('event_hub_name', id_part='child_name_1', arg_type=event_hub_name_arg_type, help='Name of EventHub')

    with self.argument_context('eventhubs eventhub authorization-rule keys renew') as c:
        c.argument('name', arg_type=name_type, help='Name of Authorization Rule')
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)

    with self.argument_context('eventhubs eventhub authorization-rule list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('event_hub_name', id_part=None, arg_type=event_hub_name_arg_type)

    with self.argument_context('eventhubs eventhub authorization-rule keys list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('event_hub_name', id_part=None, arg_type=event_hub_name_arg_type)
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='Name of EventHub AuthorizationRule')


# - ConsumerGroup Region
    with self.argument_context('eventhubs eventhub consumer-group') as c:
        c.argument('event_hub_name', arg_type=event_hub_name_arg_type, help='Name of EventHub')
        c.argument('consumer_group_name', arg_type=name_type, id_part='child_name_2', completer=get_consumergroup_command_completion_list, help='Name of ConsumerGroup')

    for scope in ['eventhubs eventhub consumer-group create', 'eventhubs eventhub consumer-group update']:
        with self.argument_context(scope) as c:
            c.argument('name', arg_type=name_type, help='Name of ConsumerGroup')
            c.argument('user_metadata', help='Usermetadata is a placeholder to store user-defined string data with maximum length 1024. e.g. it can be used to store descriptive data, such as list of teams and their contact information also user-defined configuration settings can be stored.')

    with self.argument_context('eventhubs eventhub consumer-group list') as c:
        c.argument('event_hub_name', arg_type=event_hub_name_arg_type, id_part=None, help='Name of EventHub')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

#   : Region Geo DR Configuration
    with self.argument_context('eventhubs georecovery-alias') as c:
        c.argument('alias', options_list=['--alias', '-a'], id_part='child_name_1', help='Name of Geo-Disaster Recovery Configuration Alias')

    with self.argument_context('eventhubs georecovery-alias exists') as c:
        c.argument('name', options_list=['--alias', '-a'], arg_type=name_type, help='Name of Geo Recovery Configs - Alias to check availability')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs georecovery-alias set') as c:
        c.argument('partner_namespace', required=True, validator=validate_partner_namespace, help='Name (if within the same resource group) or ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing')
        c.argument('alternate_name', help='Alternate Name for the Alias, when the Namespace name and Alias name are same')

    for scope in ['eventhubs georecovery-alias authorization-rule show']:
        with self.argument_context(scope)as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='Name of Namespace AuthorizationRule')

    with self.argument_context('eventhubs georecovery-alias list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs georecovery-alias authorization-rule list') as c:
        c.argument('alias', options_list=['--alias', '-a'], help='Name of Geo-Disaster Recovery Configuration Alias')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs georecovery-alias authorization-rule keys list') as c:
        c.argument('alias', options_list=['--alias', '-a'], id_part=None, help='Name of Geo-Disaster Recovery Configuration Alias')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('authorization_rule_name', arg_type=name_type, help='Name of Namespace AuthorizationRule')

# Region Namespace NetworkRuleSet
    with self.argument_context('eventhubs namespace network-rule', resource_type=ResourceType.MGMT_EVENTHUB, min_api='2017-04-01') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')

    for scope in ['eventhubs namespace network-rule add', 'eventhubs namespace network-rule remove']:
        with self.argument_context(scope, resource_type=ResourceType.MGMT_EVENTHUB, min_api='2017-04-01') as c:
            c.argument('subnet', arg_group='Virtual Network Rule', options_list=['--subnet'], help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
            c.argument('ip_mask', arg_group='IP Address Rule', options_list=['--ip-address'], help='IPv4 address or CIDR range - 10.6.0.0/24')
            c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')
            c.extra('vnet_name', arg_group='Virtual Network Rule', options_list=['--vnet-name'], help='Name of the Virtual Network')

    with self.argument_context('eventhubs namespace network-rule add', resource_type=ResourceType.MGMT_EVENTHUB, min_api='2017-04-01') as c:
        c.argument('ignore_missing_vnet_service_endpoint', arg_group='Virtual Network Rule', options_list=['--ignore-missing-endpoint'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether to ignore missing vnet Service Endpoint')
        c.argument('action', arg_group='IP Address Rule', options_list=['--action'], arg_type=get_enum_type(['Allow']), help='Action of the IP rule')

# Private end point connection
    with self.argument_context('eventhubs namespace private-endpoint-connection',
                               resource_type=ResourceType.MGMT_EVENTHUB) as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')
        c.argument('private_endpoint_connection_name', options_list=['--name', '-n'],
                   help='The name of the private endpoint connection associated with the EventHubs Namespace.')
    for item in ['approve', 'reject', 'show', 'delete']:
        with self.argument_context('eventhubs namespace private-endpoint-connection {}'.format(item),
                                   resource_type=ResourceType.MGMT_EVENTHUB) 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 EventHubs Namespace.')
            c.extra('connection_id', options_list=['--id'],
                    help='The ID of the private endpoint connection associated with the EventHubs Namespace. You can get '
                         'it using `az eventhubs namespace show`.')
            c.argument('namespace_name', help='The eventhubs namesapce name.', required=False)
            c.argument('resource_group_name', help='The resource group name of specified eventhubs namespace.',
                       required=False)
            c.argument('description', help='Comments for {} operation.'.format(item))

# Private end point connection
    with self.argument_context('eventhubs namespace private-link-resource',
                               resource_type=ResourceType.MGMT_EVENTHUB) as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')

# Identity
    with self.argument_context('eventhubs namespace identity',
                               resource_type=ResourceType.MGMT_EVENTHUB) as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')

    for scope in ['eventhubs namespace identity assign', 'eventhubs namespace identity remove']:
        with self.argument_context(scope, resource_type=ResourceType.MGMT_EVENTHUB) as c:
            c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')
            c.argument('system_assigned', arg_type=get_three_state_flag(), help='System Assigned Identity')
            c.argument('user_assigned', nargs='+', help='User Assigned Identity')

# Encryption
    with self.argument_context('eventhubs namespace encryption', resource_type=ResourceType.MGMT_EVENTHUB) as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')

    for scope in ['eventhubs namespace encryption add', 'eventhubs namespace identity remove']:
        with self.argument_context(scope, resource_type=ResourceType.MGMT_EVENTHUB) as c:
            c.argument('encryption_config', action=AlertAddEncryption, nargs='+', help='List of KeyVaultProperties objects.')

# Schema Registry
    with self.argument_context('eventhubs namespace schema-registry list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs namespace schema-registry') as c:
        c.argument('namespace_name', arg_type=namespace_name_arg_type, options_list=['--namespace-name'], help='name of Namespace')
        c.argument('schema_group_name', arg_type=name_type, id_part='child_name_1', help='name of schema group')

    for scope in ['eventhubs namespace schema-registry create', 'eventhubs namespace schema-registry update']:
        with self.argument_context(scope) as c:
            c.argument('schema_compatibility', options_list=['--schema-compatibility'], arg_type=get_enum_type(['None', 'Backward', 'Forward']), help='Compatibility of Schema')
            c.argument('schema_type', options_list=['--schema-type'], arg_type=get_enum_type(['Avro']), help='Type of Schema')
            c.argument('tags', options_list=['--group-properties'], arg_type=tags_type,
                       help='Type of Schema')
示例#16
0
def load_arguments(self, _):

    # pylint: disable=line-too-long
    # PARAMETER REGISTRATION
    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    sku_arg_type = CLIArgumentType(help='The pricing tiers, e.g., F1(Free), D1(Shared), B1(Basic Small), B2(Basic Medium), B3(Basic Large), S1(Standard Small), P1(Premium Small), P1V2(Premium V2 Small) etc',
                                   arg_type=get_enum_type(['F1', 'FREE', 'D1', 'SHARED', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3', 'P1V2', 'P2V2', 'P3V2']))
    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. You can configure the default using 'az configure --defaults web=<name>'")

    # use this hidden arg to give a command the right instance, that functionapp commands
    # work on function app and webapp ones work on web app
    with self.argument_context('webapp') as c:
        c.ignore('app_instance')
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('slot', options_list=['--slot', '-s'], help="the name of the slot. Default to the productions slot if not specified")
        c.argument('name', configured_default='web', arg_type=name_arg_type,
                   completer=get_resource_name_completion_list('Microsoft.Web/sites'), id_part='name',
                   help="name of the web. You can configure the default using 'az configure --defaults web=<name>'")

    with self.argument_context('appservice') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))

    with self.argument_context('appservice list-locations') as c:
        c.argument('linux_workers_enabled', action='store_true', help='get regions which support hosting webapps on Linux workers')
        c.argument('sku', arg_type=sku_arg_type)

    with self.argument_context('appservice plan') as c:
        c.argument('name', arg_type=name_arg_type, help='The name of the app service plan',
                   completer=get_resource_name_completion_list('Microsoft.Web/serverFarms'),
                   configured_default='appserviceplan', id_part='name')
        c.argument('number_of_workers', help='Number of workers to be allocated.', type=int, default=1)
        c.argument('admin_site_name', help='The name of the admin web app.')

    with self.argument_context('appservice plan create') as c:
        c.argument('name', options_list=['--name', '-n'], help="Name of the new app service plan", completer=None)
        c.argument('sku', arg_type=sku_arg_type)
        c.argument('is_linux', action='store_true', required=False, help='host webapp on Linux worker')
    with self.argument_context('appservice plan update') as c:
        c.argument('sku', arg_type=sku_arg_type)
        c.ignore('allow_pending_state')

    with self.argument_context('webapp create') as c:
        c.argument('name', options_list=['--name', '-n'], help='name of the new webapp')
        c.argument('startup_file', help="Linux only. The web's startup file")
        c.argument('multicontainer_config_type', options_list=['--multicontainer-config-type'], help="Linux only.", arg_type=get_enum_type(MULTI_CONTAINER_TYPES))
        c.argument('multicontainer_config_file', options_list=['--multicontainer-config-file'], help="Linux only. Config file for multicontainer apps. (local or remote)")
        c.argument('runtime', options_list=['--runtime', '-r'], help="canonicalized web runtime in the format of Framework|Version, e.g. \"PHP|5.6\". Use 'az webapp list-runtimes' for available list")  # TODO ADD completer
        c.argument('plan', options_list=['--plan', '-p'], configured_default='appserviceplan',
                   completer=get_resource_name_completion_list('Microsoft.Web/serverFarms'),
                   help="name or resource id of the app service plan. Use 'appservice plan create' to get one")

    with self.argument_context('webapp show') as c:
        c.argument('name', arg_type=webapp_name_arg_type)

    with self.argument_context('webapp list-runtimes') as c:
        c.argument('linux', action='store_true', help='list runtime stacks for linux based webapps')

    with self.argument_context('webapp traffic-routing') as c:
        c.argument('distribution', options_list=['--distribution', '-d'], nargs='+', help='space-separated slot routings in a format of <slot-name>=<percentage> e.g. staging=50. Unused traffic percentage will go to the Production slot')

    with self.argument_context('webapp update') as c:
        c.argument('client_affinity_enabled', help="Enables sending session affinity cookies.", arg_type=get_three_state_flag(return_label=True))
        c.argument('https_only', help="Redirect all traffic made to an app using HTTP to HTTPS.", arg_type=get_three_state_flag(return_label=True))
        c.argument('force_dns_registration', help="If true, web app hostname is force registered with DNS", arg_type=get_three_state_flag(return_label=True))
        c.argument('skip_custom_domain_verification', help="If true, custom (non *.azurewebsites.net) domains associated with web app are not verified", arg_type=get_three_state_flag(return_label=True))
        c.argument('ttl_in_seconds', help="Time to live in seconds for web app's default domain name", arg_type=get_three_state_flag(return_label=True))
        c.argument('skip_dns_registration', help="If true web app hostname is not registered with DNS on creation", arg_type=get_three_state_flag(return_label=True))

    with self.argument_context('webapp browse') as c:
        c.argument('logs', options_list=['--logs', '-l'], action='store_true', help='Enable viewing the log stream immediately after launching the web app')
    with self.argument_context('webapp delete') as c:
        c.argument('keep_empty_plan', action='store_true', help='keep empty app service plan')
        c.argument('keep_metrics', action='store_true', help='keep app metrics')
        c.argument('keep_dns_registration', action='store_true', help='keep DNS registration')

    for scope in ['webapp', 'functionapp']:
        with self.argument_context(scope + ' create') as c:
            c.argument('deployment_container_image_name', options_list=['--deployment-container-image-name', '-i'], help='Linux only. Container image name from Docker Hub, e.g. publisher/image-name:tag')
            c.argument('deployment_local_git', action='store_true', options_list=['--deployment-local-git', '-l'], help='enable local git')
            c.argument('deployment_zip', options_list=['--deployment-zip', '-z'], help='perform deployment using zip file')
            c.argument('deployment_source_url', options_list=['--deployment-source-url', '-u'], help='Git repository URL to link with manual integration')
            c.argument('deployment_source_branch', options_list=['--deployment-source-branch', '-b'], help='the branch to deploy')
        with self.argument_context(scope + ' config ssl bind') as c:
            c.argument('ssl_type', help='The ssl cert type', arg_type=get_enum_type(['SNI', 'IP']))
        with self.argument_context(scope + ' config ssl upload') as c:
            c.argument('certificate_password', help='The ssl cert password')
            c.argument('certificate_file', type=file_type, help='The filepath for the .pfx file')
        with self.argument_context(scope + ' config ssl') as c:
            c.argument('certificate_thumbprint', help='The ssl cert thumbprint')
        with self.argument_context(scope + ' config appsettings') as c:
            c.argument('settings', nargs='+', help="space-separated app settings in a format of <name>=<value>")
            c.argument('setting_names', nargs='+', help="space-separated app setting names")

        with self.argument_context(scope + ' config hostname') as c:
            c.argument('hostname', completer=get_hostname_completion_list, help="hostname assigned to the site, such as custom domains", id_part='child_name_1')
        with self.argument_context(scope + ' deployment user') as c:
            c.argument('user_name', help='user name')
            c.argument('password', help='password, will prompt if not specified')
        with self.argument_context(scope + ' deployment source') as c:
            c.argument('manual_integration', action='store_true', help='disable automatic sync between source control and web')
            c.argument('repo_url', options_list=['--repo-url', '-u'], help='repository url to pull the latest source from, e.g. https://github.com/foo/foo-web')
            c.argument('branch', help='the branch name of the repository')
            c.argument('private_repo_username', arg_group='VSTS CD Provider', help='Username for the private repository')
            c.argument('private_repo_password', arg_group='VSTS CD Provider', help='Password for the private repository')
            c.argument('cd_app_type', arg_group='VSTS CD Provider', help='Web application framework you used to develop your app. Default is AspNet.', arg_type=get_enum_type(['AspNet', 'AspNetCore', 'NodeJS', 'PHP', 'Python']))
            c.argument('app_working_dir', arg_group='VSTS CD Provider', help='Working directory of the application. Default will be root of the repo')
            c.argument('nodejs_task_runner', arg_group='VSTS CD Provider', help='Task runner for nodejs. Default is None', arg_type=get_enum_type(['None', 'Gulp', 'Grunt']))
            c.argument('python_framework', arg_group='VSTS CD Provider', help='Framework used for Python application. Default is Django', arg_type=get_enum_type(['Bottle', 'Django', 'Flask']))
            c.argument('python_version', arg_group='VSTS CD Provider', help='Python version used for application. Default is Python 3.5.3 x86', arg_type=get_enum_type(['Python 2.7.12 x64', 'Python 2.7.12 x86', 'Python 2.7.13 x64', 'Python 2.7.13 x86', 'Python 3.5.3 x64', 'Python 3.5.3 x86', 'Python 3.6.0 x64', 'Python 3.6.0 x86', 'Python 3.6.2 x64', 'Python 3.6.1 x86']))
            c.argument('cd_project_url', arg_group='VSTS CD Provider', help='URL of the Visual Studio Team Services (VSTS) project to use for continuous delivery. URL should be in format https://<accountname>.visualstudio.com/<projectname>')
            c.argument('cd_account_create', arg_group='VSTS CD Provider', help="To create a new Visual Studio Team Services (VSTS) account if it doesn't exist already", action='store_true')
            c.argument('test', arg_group='VSTS CD Provider', help='Name of the web app to be used for load testing. If web app is not available, it will be created. Default: Disable')
            c.argument('slot_swap', arg_group='VSTS CD Provider', help='Name of the slot to be used for deployment and later promote to production. If slot is not available, it will be created. Default: Not configured')
            c.argument('repository_type', help='repository type', arg_type=get_enum_type(['git', 'mercurial', 'vsts', 'github', 'externalgit', 'localgit']))
            c.argument('git_token', help='Git access token required for auto sync')
        with self.argument_context(scope + ' identity') as c:
            c.argument('scope', help="The scope the managed identity has access to")
            c.argument('role', help="Role name or id the managed identity will be assigned")

        with self.argument_context(scope + ' deployment source config-zip') as c:
            c.argument('src', help='a zip file path for deployment')

        with self.argument_context(scope + ' config appsettings list') as c:
            c.argument('name', arg_type=webapp_name_arg_type, id_part=None)

        with self.argument_context(scope + ' config hostname list') as c:
            c.argument('webapp_name', arg_type=webapp_name_arg_type, id_part=None, options_list='--webapp-name')

    with self.argument_context('webapp config connection-string list') as c:
        c.argument('name', arg_type=webapp_name_arg_type, id_part=None)

    with self.argument_context('webapp config hostname') as c:
        c.argument('webapp_name', help="webapp name. You can configure the default using 'az configure --defaults web=<name>'", configured_default='web',
                   completer=get_resource_name_completion_list('Microsoft.Web/sites'), id_part='name')
    with self.argument_context('webapp deployment container config') as c:
        c.argument('enable', options_list=['--enable-cd', '-e'], help='enable/disable continuous deployment', arg_type=get_enum_type(['true', 'false']))
    with self.argument_context('webapp deployment slot') as c:
        c.argument('slot', help='the name of the slot')
        c.argument('webapp', arg_type=name_arg_type, completer=get_resource_name_completion_list('Microsoft.Web/sites'),
                   help='Name of the webapp', id_part='name')
        c.argument('auto_swap_slot', help='target slot to auto swap', default='production')
        c.argument('disable', help='disable auto swap', action='store_true')
        c.argument('target_slot', help="target slot to swap, default to 'production'")
    with self.argument_context('webapp deployment slot create') as c:
        c.argument('configuration_source', help="source slot to clone configurations from. Use webapp's name to refer to the production slot")
    with self.argument_context('webapp deployment slot swap') as c:
        c.argument('action', help="swap types. use 'preview' to apply target slot's settings on the source slot first; use 'swap' to complete it; use 'reset' to reset the swap",
                   arg_type=get_enum_type(['swap', 'preview', 'reset']))
    with self.argument_context('webapp log config') as c:
        c.argument('application_logging', help='configure application logging to file system', arg_type=get_three_state_flag(return_label=True))
        c.argument('detailed_error_messages', help='configure detailed error messages', arg_type=get_three_state_flag(return_label=True))
        c.argument('failed_request_tracing', help='configure failed request tracing', arg_type=get_three_state_flag(return_label=True))
        c.argument('level', help='logging level', arg_type=get_enum_type(['error', 'warning', 'information', 'verbose']))
        c.argument('web_server_logging', help='configure Web server logging', arg_type=get_enum_type(['off', 'filesystem']))
        c.argument('docker_container_logging', help='configure gathering STDOUT and STDERR output from container', arg_type=get_enum_type(['off', 'filesystem']))

    with self.argument_context('webapp log tail') as c:
        c.argument('provider', help="By default all live traces configured by 'az webapp log config' will be shown, but you can scope to certain providers/folders, e.g. 'application', 'http', etc. For details, check out https://github.com/projectkudu/kudu/wiki/Diagnostic-Log-Stream")
    with self.argument_context('webapp log download') as c:
        c.argument('log_file', default='webapp_logs.zip', type=file_type, completer=FilesCompleter(), help='the downloaded zipped log file path')

    for scope in ['appsettings', 'connection-string']:
        with self.argument_context('webapp config ' + scope) as c:
            c.argument('settings', nargs='+', help="space-separated {} in a format of <name>=<value>".format(scope))
            c.argument('slot_settings', nargs='+', help="space-separated slot {} in a format of <name>=<value>".format(scope))
            c.argument('setting_names', nargs='+', help="space-separated {} names".format(scope))

    with self.argument_context('webapp config connection-string') as c:
        c.argument('connection_string_type', options_list=['--connection-string-type', '-t'], help='connection string type', arg_type=get_enum_type(ConnectionStringType))

    with self.argument_context('webapp config container') as c:
        c.argument('docker_registry_server_url', options_list=['--docker-registry-server-url', '-r'], help='the container registry server url')
        c.argument('docker_custom_image_name', options_list=['--docker-custom-image-name', '-c', '-i'], help='the container custom image name and optionally the tag name')
        c.argument('docker_registry_server_user', options_list=['--docker-registry-server-user', '-u'], help='the container registry server username')
        c.argument('docker_registry_server_password', options_list=['--docker-registry-server-password', '-p'], help='the container registry server password')
        c.argument('websites_enable_app_service_storage', options_list=['--enable-app-service-storage', '-t'], help='enables platform storage (custom container only)', arg_type=get_three_state_flag(return_label=True))
        c.argument('multicontainer_config_type', options_list=['--multicontainer-config-type'], help='config type', arg_type=get_enum_type(MULTI_CONTAINER_TYPES))
        c.argument('multicontainer_config_file', options_list=['--multicontainer-config-file'], help="config file for multicontainer apps")
        c.argument('show_multicontainer_config', action='store_true', help='shows decoded config if a multicontainer config is set')

    with self.argument_context('webapp config set') as c:
        c.argument('remote_debugging_enabled', help='enable or disable remote debugging', arg_type=get_three_state_flag(return_label=True))
        c.argument('web_sockets_enabled', help='enable or disable web sockets', arg_type=get_three_state_flag(return_label=True))
        c.argument('always_on', help='ensure webapp gets loaded all the time, rather unloaded after been idle. Recommended when you have continuous web jobs running', arg_type=get_three_state_flag(return_label=True))
        c.argument('auto_heal_enabled', help='enable or disable auto heal', arg_type=get_three_state_flag(return_label=True))
        c.argument('use32_bit_worker_process', options_list=['--use-32bit-worker-process'], help='use 32 bits worker process or not', arg_type=get_three_state_flag(return_label=True))
        c.argument('php_version', help='The version used to run your web app if using PHP, e.g., 5.5, 5.6, 7.0')
        c.argument('python_version', help='The version used to run your web app if using Python, e.g., 2.7, 3.4')
        c.argument('net_framework_version', help="The version used to run your web app if using .NET Framework, e.g., 'v4.0' for .NET 4.6 and 'v3.0' for .NET 3.5")
        c.argument('linux_fx_version', help="The runtime stack used for your linux-based webapp, e.g., \"RUBY|2.3\", \"NODE|6.6\", \"PHP|5.6\", \"DOTNETCORE|1.1.0\". See https://aka.ms/linux-stacks for more info.")
        c.argument('java_version', help="The version used to run your web app if using Java, e.g., '1.7' for Java 7, '1.8' for Java 8")
        c.argument('java_container', help="The java container, e.g., Tomcat, Jetty")
        c.argument('java_container_version', help="The version of the java container, e.g., '8.0.23' for Tomcat")
        c.argument('min_tls_version', help="The minimum version of TLS required for SSL requests, e.g., '1.0', '1.1', '1.2'")
        c.argument('http20_enabled', help="configures a web site to allow clients to connect over http2.0.", arg_type=get_three_state_flag(return_label=True))
        c.argument('app_command_line', options_list=['--startup-file'], help="The startup file for linux hosted web apps, e.g. 'process.json' for Node.js web")

    with self.argument_context('webapp config backup') as c:
        c.argument('storage_account_url', help='URL with SAS token to the blob storage container', options_list=['--container-url'])
        c.argument('webapp_name', help='The name of the webapp')
        c.argument('db_name', help='Name of the database in the backup', arg_group='Database')
        c.argument('db_connection_string', help='Connection string for the database in the backup', arg_group='Database')
        c.argument('db_type', help='Type of database in the backup', arg_group='Database', arg_type=get_enum_type(DatabaseType))

    with self.argument_context('webapp config backup create') as c:
        c.argument('backup_name', help='Name of the backup. If unspecified, the backup will be named with the webapp name and a timestamp')

    with self.argument_context('webapp config backup update') as c:
        c.argument('backup_name', help='Name of the backup. If unspecified, the backup will be named with the webapp name and a timestamp')
        c.argument('frequency', help='How often to backup. Use a number followed by d or h, e.g. 5d = 5 days, 2h = 2 hours')
        c.argument('keep_at_least_one_backup', help='Always keep one backup, regardless of how old it is', options_list=['--retain-one'], arg_type=get_three_state_flag(return_label=True))
        c.argument('retention_period_in_days', help='How many days to keep a backup before automatically deleting it. Set to 0 for indefinite retention', options_list=['--retention'])

    with self.argument_context('webapp config backup restore') as c:
        c.argument('backup_name', help='Name of the backup to restore')
        c.argument('target_name', help='The name to use for the restored webapp. If unspecified, will default to the name that was used when the backup was created')
        c.argument('overwrite', help='Overwrite the source webapp, if --target-name is not specified', action='store_true')
        c.argument('ignore_hostname_conflict', help='Ignores custom hostnames stored in the backup', action='store_true')

    with self.argument_context('webapp auth update') as c:
        c.argument('enabled', arg_type=get_three_state_flag(return_label=True))
        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))
        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, help="Hours, must be formattable into a float")
        c.argument('allowed_external_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('allowed_audiences', nargs='+', options_list=['--aad-allowed-token-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_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', help='Twitter Application client secret')
        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_oauth_scopes', nargs='+', help="One or more Google authentication scopes (space-delimited).", arg_group='Google')
        c.argument('microsoft_account_client_id', arg_group='Microsoft', help="AAD V2 Application ID to integrate Microsoft account Sign-in into your web app")
        c.argument('microsoft_account_client_secret', arg_group='Microsoft', help='AAD V2 Application client secret')
        c.argument('microsoft_account_oauth_scopes', nargs='+', help="One or more Microsoft authentification scopes (space-delimited).", arg_group='Microsoft')

    with self.argument_context('functionapp') as c:
        c.ignore('app_instance', 'slot')
        c.argument('name', arg_type=name_arg_type, id_part='name', help='name of the function app')
    with self.argument_context('functionapp config hostname') as c:
        c.argument('webapp_name', arg_type=name_arg_type, id_part='name', help='name of the function app')
    with self.argument_context('functionapp create') as c:
        c.argument('plan', options_list=['--plan', '-p'], configured_default='appserviceplan',
                   completer=get_resource_name_completion_list('Microsoft.Web/serverFarms'),
                   help="name or resource id of the function app service plan. Use 'appservice plan create' to get one")
        c.argument('new_app_name', options_list=['--name', '-n'], help='name of the new function app')
        c.argument('storage_account', options_list=['--storage-account', '-s'],
                   help='Provide a string value of a Storage Account in the provided Resource Group. Or Resource ID of a Storage Account in a different Resource Group')
        c.argument('consumption_plan_location', options_list=['--consumption-plan-location', '-c'],
                   help="Geographic location where Function App will be hosted. Use 'functionapp list-consumption-locations' to view available locations.")
    # For commands with shared impl between webapp and functionapp and has output, we apply type validation to avoid confusions
    with self.argument_context('functionapp show') as c:
        c.argument('name', arg_type=name_arg_type)
    with self.argument_context('functionapp config appsettings') as c:
        c.argument('slot_settings', nargs='+', help="space-separated slot app settings in a format of <name>=<value>")
示例#17
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.')
示例#18
0
def load_arguments(self, _):

    name_type = CLIArgumentType(options_list=['--name', '-n'])

    with self.argument_context('containerapp') as c:
        # Base arguments
        c.argument('name',
                   name_type,
                   metavar='NAME',
                   id_part='name',
                   help="The name of the Containerapp.")
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.ignore('disable_warnings')

    with self.argument_context('containerapp') as c:
        c.argument('tags', arg_type=tags_type)
        c.argument(
            'managed_env',
            validator=validate_managed_env_name_or_id,
            options_list=['--environment'],
            help="Name or resource ID of the container app's environment.")
        c.argument(
            'yaml',
            type=file_type,
            help=
            'Path to a .yaml file with the configuration of a container app. All other parameters will be ignored. For an example, see  https://docs.microsoft.com/azure/container-apps/azure-resource-manager-api-spec#examples'
        )

    with self.argument_context('containerapp exec') as c:
        c.argument('container', help="The name of the container to ssh into")
        c.argument(
            'replica',
            help=
            "The name of the replica to ssh into. List replicas with 'az containerapp replica list'. A replica may not exist if there is not traffic to your app."
        )
        c.argument(
            'revision',
            help=
            "The name of the container app revision to ssh into. Defaults to the latest revision."
        )
        c.argument('startup_command',
                   options_list=["--command"],
                   help="The startup command (bash, zsh, sh, etc.).")
        c.argument('name',
                   name_type,
                   id_part=None,
                   help="The name of the Containerapp.")
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   id_part=None)

    with self.argument_context('containerapp logs show') as c:
        c.argument('follow',
                   help="Print logs in real time if present.",
                   arg_type=get_three_state_flag())
        c.argument('tail',
                   help="The number of past logs to print (0-300)",
                   type=int,
                   default=20)
        c.argument('container', help="The name of the container")
        c.argument('output_format',
                   options_list=["--format"],
                   help="Log output format",
                   arg_type=get_enum_type(["json", "text"]),
                   default="json")
        c.argument(
            'replica',
            help=
            "The name of the replica. List replicas with 'az containerapp replica list'. A replica may not exist if there is not traffic to your app."
        )
        c.argument(
            'revision',
            help=
            "The name of the container app revision. Defaults to the latest revision."
        )
        c.argument('name',
                   name_type,
                   id_part=None,
                   help="The name of the Containerapp.")
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   id_part=None)

    # Replica
    with self.argument_context('containerapp replica') as c:
        c.argument('replica', help="The name of the replica. ")
        c.argument(
            'revision',
            help=
            "The name of the container app revision. Defaults to the latest revision."
        )
        c.argument('name',
                   name_type,
                   id_part=None,
                   help="The name of the Containerapp.")
        c.argument('resource_group_name',
                   arg_type=resource_group_name_type,
                   id_part=None)

    # Container
    with self.argument_context('containerapp', arg_group='Container') as c:
        c.argument('container_name', help="Name of the container.")
        c.argument('cpu',
                   type=float,
                   validator=validate_cpu,
                   help="Required CPU in cores from 0.25 - 2.0, e.g. 0.5")
        c.argument(
            'memory',
            validator=validate_memory,
            help="Required memory from 0.5 - 4.0 ending with \"Gi\", e.g. 1.0Gi"
        )
        c.argument(
            'env_vars',
            nargs='*',
            help=
            "A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret."
        )
        c.argument(
            'startup_command',
            nargs='*',
            options_list=['--command'],
            help=
            "A list of supported commands on the container that will executed during startup. Space-separated values e.g. \"/bin/queue\" \"mycommand\". Empty string to clear existing values"
        )
        c.argument(
            'args',
            nargs='*',
            help=
            "A list of container startup command argument(s). Space-separated values e.g. \"-c\" \"mycommand\". Empty string to clear existing values"
        )
        c.argument(
            'revision_suffix',
            help='User friendly suffix that is appended to the revision name')

    # Env vars
    with self.argument_context('containerapp',
                               arg_group='Environment variables') as c:
        c.argument(
            'set_env_vars',
            nargs='*',
            help=
            "Add or update environment variable(s) in container. Existing environmentenvironment variables are not modified. Space-separated values in 'key=value' format. If stored as a secret, value must start with 'secretref:' followed by the secret name."
        )
        c.argument(
            'remove_env_vars',
            nargs='*',
            help=
            "Remove environment variable(s) from container. Space-separated environment variable names."
        )
        c.argument(
            'replace_env_vars',
            nargs='*',
            help=
            "Replace environment variable(s) in container. Other existing environment variables are removed. Space-separated values in 'key=value' format. If stored as a secret, value must start with 'secretref:' followed by the secret name."
        )
        c.argument('remove_all_env_vars',
                   help="Remove all environment variable(s) from container..")

    # Scale
    with self.argument_context('containerapp', arg_group='Scale') as c:
        c.argument('min_replicas',
                   type=int,
                   help="The minimum number of replicas.")
        c.argument('max_replicas',
                   type=int,
                   help="The maximum number of replicas.")

    # Dapr
    with self.argument_context('containerapp', arg_group='Dapr') as c:
        c.argument('dapr_enabled',
                   options_list=['--enable-dapr'],
                   default=False,
                   arg_type=get_three_state_flag(),
                   help="Boolean indicating if the Dapr side car is enabled.")
        c.argument('dapr_app_port',
                   type=int,
                   help="The port Dapr uses to talk to the application.")
        c.argument('dapr_app_id', help="The Dapr application identifier.")
        c.argument('dapr_app_protocol',
                   arg_type=get_enum_type(['http', 'grpc']),
                   help="The protocol Dapr uses to talk to the application.")

    # Configuration
    with self.argument_context('containerapp', arg_group='Configuration') as c:
        c.argument('revisions_mode',
                   arg_type=get_enum_type(['single', 'multiple']),
                   help="The active revisions mode for the container app.")
        c.argument(
            'registry_server',
            validator=validate_registry_server,
            help=
            "The container registry server hostname, e.g. myregistry.azurecr.io."
        )
        c.argument(
            'registry_pass',
            validator=validate_registry_pass,
            options_list=['--registry-password'],
            help=
            "The password to log in to container registry. If stored as a secret, value must start with \'secretref:\' followed by the secret name."
        )
        c.argument('registry_user',
                   validator=validate_registry_user,
                   options_list=['--registry-username'],
                   help="The username to log in to container registry.")
        c.argument(
            'secrets',
            nargs='*',
            options_list=['--secrets', '-s'],
            help=
            "A list of secret(s) for the container app. Space-separated values in 'key=value' format."
        )

    # Ingress
    with self.argument_context('containerapp', arg_group='Ingress') as c:
        c.argument('ingress',
                   validator=validate_ingress,
                   default=None,
                   arg_type=get_enum_type(['internal', 'external']),
                   help="The ingress type.")
        c.argument('target_port',
                   type=int,
                   validator=validate_target_port,
                   help="The application port used for ingress traffic.")
        c.argument('transport',
                   arg_type=get_enum_type(['auto', 'http', 'http2']),
                   help="The transport protocol used for ingress traffic.")

    with self.argument_context('containerapp create') as c:
        c.argument(
            'traffic_weights',
            nargs='*',
            options_list=['--traffic-weight'],
            help=
            "A list of revision weight(s) for the container app. Space-separated values in 'revision_name=weight' format. For latest revision, use 'latest=weight'"
        )

    with self.argument_context('containerapp create',
                               arg_group='Identity') as c:
        c.argument('user_assigned',
                   nargs='+',
                   help="Space-separated user identities to be assigned.")
        c.argument(
            'system_assigned',
            help=
            "Boolean indicating whether to assign system-assigned identity.")

    with self.argument_context('containerapp create',
                               arg_group='Container') as c:
        c.argument('image',
                   options_list=['--image', '-i'],
                   help="Container image, e.g. publisher/image-name:tag.")

    with self.argument_context('containerapp update',
                               arg_group='Container') as c:
        c.argument('image',
                   options_list=['--image', '-i'],
                   help="Container image, e.g. publisher/image-name:tag.")

    with self.argument_context('containerapp scale') as c:
        c.argument('min_replicas',
                   type=int,
                   help="The minimum number of replicas.")
        c.argument('max_replicas',
                   type=int,
                   help="The maximum number of replicas.")

    with self.argument_context('containerapp env') as c:
        c.argument('name',
                   name_type,
                   help='Name of the Container Apps environment.')
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   help='Location of resource. Examples: eastus2, northeurope')
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('containerapp env',
                               arg_group='Log Analytics') as c:
        c.argument(
            'logs_customer_id',
            options_list=['--logs-workspace-id'],
            help=
            'Name or resource ID of the Log Analytics workspace to send diagnostics logs to. You can use \"az monitor log-analytics workspace create\" to create one. Extra billing may apply.'
        )
        c.argument(
            'logs_key',
            options_list=['--logs-workspace-key'],
            help=
            'Log Analytics workspace key to configure your Log Analytics workspace. You can use \"az monitor log-analytics workspace get-shared-keys\" to retrieve the key.'
        )

    with self.argument_context('containerapp env', arg_group='Dapr') as c:
        c.argument(
            'instrumentation_key',
            options_list=['--dapr-instrumentation-key'],
            help=
            'Application Insights instrumentation key used by Dapr to export Service to Service communication telemetry'
        )

    with self.argument_context('containerapp env',
                               arg_group='Virtual Network') as c:
        c.argument(
            'infrastructure_subnet_resource_id',
            options_list=['--infrastructure-subnet-resource-id'],
            help=
            'Resource ID of a subnet for infrastructure components and user app containers.'
        )
        c.argument(
            'app_subnet_resource_id',
            options_list=['--app-subnet-resource-id'],
            help=
            'Resource ID of a subnet that Container App containers are injected into. This subnet must be in the same VNET as the subnet defined in infrastructureSubnetResourceId.'
        )
        c.argument(
            'docker_bridge_cidr',
            options_list=['--docker-bridge-cidr'],
            help=
            'CIDR notation IP range assigned to the Docker bridge. It must not overlap with any Subnet IP ranges or the IP range defined in Platform Reserved CIDR, if defined'
        )
        c.argument(
            'platform_reserved_cidr',
            options_list=['--platform-reserved-cidr'],
            help=
            'IP range in CIDR notation that can be reserved for environment infrastructure IP addresses. It must not overlap with any other Subnet IP ranges'
        )
        c.argument(
            'platform_reserved_dns_ip',
            options_list=['--platform-reserved-dns-ip'],
            help=
            'An IP address from the IP range defined by Platform Reserved CIDR that will be reserved for the internal DNS server.'
        )
        c.argument(
            'internal_only',
            arg_type=get_three_state_flag(),
            options_list=['--internal-only'],
            help=
            'Boolean indicating the environment only has an internal load balancer. These environments do not have a public static IP resource, therefore must provide infrastructureSubnetResourceId and appSubnetResourceId if enabling this property'
        )

    with self.argument_context('containerapp env update') as c:
        c.argument('name',
                   name_type,
                   help='Name of the Container Apps environment.')
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('containerapp env delete') as c:
        c.argument('name',
                   name_type,
                   help='Name of the Container Apps Environment.')

    with self.argument_context('containerapp env show') as c:
        c.argument('name',
                   name_type,
                   help='Name of the Container Apps Environment.')

    with self.argument_context('containerapp identity') as c:
        c.argument('user_assigned',
                   nargs='+',
                   help="Space-separated user identities.")
        c.argument(
            'system_assigned',
            help=
            "Boolean indicating whether to assign system-assigned identity.")

    with self.argument_context('containerapp identity remove') as c:
        c.argument(
            'user_assigned',
            nargs='*',
            help=
            "Space-separated user identities. If no user identities are specified, all user identities will be removed."
        )

    with self.argument_context('containerapp github-action add') as c:
        c.argument(
            'repo_url',
            help=
            'The GitHub repository to which the workflow file will be added. In the format: https://github.com/<owner>/<repository-name>'
        )
        c.argument(
            'token',
            help=
            'A Personal Access Token with write access to the specified repository. For more information: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line'
        )
        c.argument(
            'branch',
            options_list=['--branch', '-b'],
            help=
            'The branch of the GitHub repo. Defaults to "main" if not specified.'
        )
        c.argument(
            'login_with_github',
            help=
            'Interactively log in with Github to retrieve the Personal Access Token'
        )
        c.argument(
            'registry_url',
            help='The container registry server, e.g. myregistry.azurecr.io')
        c.argument(
            'registry_username',
            help=
            'The username of the registry. If using Azure Container Registry, we will try to infer the credentials if not supplied'
        )
        c.argument(
            'registry_password',
            help=
            'The password of the registry. If using Azure Container Registry, we will try to infer the credentials if not supplied'
        )
        c.argument(
            'context_path',
            help=
            'Path in the repo from which to run the docker build. Defaults to "./"'
        )
        c.argument('service_principal_client_id',
                   help='The service principal client ID. ')
        c.argument('service_principal_client_secret',
                   help='The service principal client secret.')
        c.argument('service_principal_tenant_id',
                   help='The service principal tenant ID.')
        c.argument(
            'image',
            options_list=['--image', '-i'],
            help=
            "Container image name that the Github Action should use. Defaults to the Container App name."
        )

    with self.argument_context('containerapp github-action delete') as c:
        c.argument(
            'token',
            help=
            'A Personal Access Token with write access to the specified repository. For more information: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line'
        )
        c.argument(
            'login_with_github',
            help=
            'Interactively log in with Github to retrieve the Personal Access Token'
        )

    with self.argument_context('containerapp revision') as c:
        c.argument('revision_name',
                   options_list=['--revision'],
                   help='Name of the revision.')

    with self.argument_context('containerapp revision copy') as c:
        c.argument('from_revision',
                   help='Revision to copy from. Default: latest revision.')
        c.argument('image',
                   options_list=['--image', '-i'],
                   help="Container image, e.g. publisher/image-name:tag.")

    with self.argument_context('containerapp ingress') as c:
        c.argument('allow_insecure',
                   help='Allow insecure connections for ingress traffic.')
        c.argument('type',
                   validator=validate_ingress,
                   arg_type=get_enum_type(['internal', 'external']),
                   help="The ingress type.")
        c.argument('transport',
                   arg_type=get_enum_type(['auto', 'http', 'http2']),
                   help="The transport protocol used for ingress traffic.")
        c.argument('target_port',
                   type=int,
                   validator=validate_target_port,
                   help="The application port used for ingress traffic.")

    with self.argument_context('containerapp ingress traffic') as c:
        c.argument(
            'traffic_weights',
            nargs='*',
            options_list=['--traffic-weight'],
            help=
            "A list of revision weight(s) for the container app. Space-separated values in 'revision_name=weight' format. For latest revision, use 'latest=weight'"
        )

    with self.argument_context('containerapp secret') as c:
        c.argument(
            'secrets',
            nargs='+',
            options_list=['--secrets', '-s'],
            help=
            "A list of secret(s) for the container app. Space-separated values in 'key=value' format (where 'key' cannot be longer than 20 characters)."
        )
        c.argument('secret_name', help="The name of the secret to show.")
        c.argument(
            'secret_names',
            nargs='+',
            help=
            "A list of secret(s) for the container app. Space-separated secret values names."
        )
        c.argument('show_values', help='Show the secret values.')

    with self.argument_context('containerapp env dapr-component') as c:
        c.argument('dapr_app_id', help="The Dapr app ID.")
        c.argument('dapr_app_port', help="The port of your app.")
        c.argument(
            'dapr_app_protocol',
            help=
            "Tell Dapr which protocol your application is using.  Allowed values: grpc, http."
        )
        c.argument('dapr_component_name', help="The Dapr component name.")
        c.argument('environment_name',
                   options_list=['--name', '-n'],
                   help="The environment name.")

    with self.argument_context('containerapp revision set-mode') as c:
        c.argument('mode',
                   arg_type=get_enum_type(['single', 'multiple']),
                   help="The active revisions mode for the container app.")

    with self.argument_context('containerapp registry') as c:
        c.argument(
            'server',
            help="The container registry server, e.g. myregistry.azurecr.io")
        c.argument(
            'username',
            help=
            'The username of the registry. If using Azure Container Registry, we will try to infer the credentials if not supplied'
        )
        c.argument(
            'password',
            help=
            'The password of the registry. If using Azure Container Registry, we will try to infer the credentials if not supplied'
        )

    with self.argument_context('containerapp registry list') as c:
        c.argument('name', id_part=None)

    with self.argument_context('containerapp secret list') as c:
        c.argument('name', id_part=None)

    with self.argument_context('containerapp revision list') as c:
        c.argument('name', id_part=None)

    with self.argument_context('containerapp up') as c:
        c.argument('resource_group_name',
                   configured_default='resource_group_name',
                   id_part=None)
        c.argument('location', configured_default='location')
        c.argument('name', configured_default='name', id_part=None)
        c.argument('managed_env', configured_default='managed_env')
        c.argument('registry_server', configured_default='registry_server')
        c.argument(
            'source',
            help='Local directory path to upload to Azure container registry.')
        c.argument('image',
                   options_list=['--image', '-i'],
                   help="Container image, e.g. publisher/image-name:tag.")
        c.argument(
            'browse',
            help=
            'Open the app in a web browser after creation and deployment, if possible.'
        )

    with self.argument_context('containerapp up',
                               arg_group='Log Analytics (Environment)') as c:
        c.argument(
            'logs_customer_id',
            options_list=['--logs-workspace-id'],
            help=
            'Name or resource ID of the Log Analytics workspace to send diagnostics logs to. You can use \"az monitor log-analytics workspace create\" to create one. Extra billing may apply.'
        )
        c.argument(
            'logs_key',
            options_list=['--logs-workspace-key'],
            help=
            'Log Analytics workspace key to configure your Log Analytics workspace. You can use \"az monitor log-analytics workspace get-shared-keys\" to retrieve the key.'
        )
        c.ignore('no_wait')

    with self.argument_context('containerapp up',
                               arg_group='Github Repo') as c:
        c.argument(
            'repo',
            help=
            'Create an app via Github Actions. In the format: https://github.com/<owner>/<repository-name> or <owner>/<repository-name>'
        )
        c.argument(
            'token',
            help=
            'A Personal Access Token with write access to the specified repository. For more information: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line. If missing (and using --repo), a browser page will be opened to authenticate with Github.'
        )
        c.argument('branch',
                   options_list=['--branch', '-b'],
                   help='The branch of the GitHub repo. Defaults to "main"')
        c.argument(
            'context_path',
            help=
            'Path in the repo from which to run the docker build. Defaults to "./". Dockerfile is assumed to be named "Dockerfile" and in this directory.'
        )
        c.argument(
            'service_principal_client_id',
            help=
            'The service principal client ID. Used by Github Actions to authenticate with Azure.',
            options_list=["--service-principal-client-id", "--sp-cid"])
        c.argument(
            'service_principal_client_secret',
            help=
            'The service principal client secret. Used by Github Actions to authenticate with Azure.',
            options_list=["--service-principal-client-secret", "--sp-sec"])
        c.argument(
            'service_principal_tenant_id',
            help=
            'The service principal tenant ID. Used by Github Actions to authenticate with Azure.',
            options_list=["--service-principal-tenant-id", "--sp-tid"])
示例#19
0
def load_arguments_sb(self, _):
    from azure.cli.command_modules.servicebus._completers import get_queue_command_completion_list, \
        get_rules_command_completion_list, get_subscriptions_command_completion_list, get_topic_command_completion_list
    from azure.cli.command_modules.servicebus._validators import _validate_auto_delete_on_idle, \
        _validate_duplicate_detection_history_time_window, \
        _validate_default_message_time_to_live, \
        _validate_lock_duration, validate_partner_namespace, validate_premiumsku_capacity, validate_target_namespace

    from knack.arguments import CLIArgumentType
    from azure.mgmt.servicebus.models import SkuName, AccessRights, KeyType, FilterType
    rights_arg_type = CLIArgumentType(options_list=['--rights'], nargs='+', arg_type=get_enum_type(AccessRights), help='Space-separated list of Authorization rule rights')
    key_arg_type = CLIArgumentType(options_list=['--key'], arg_type=get_enum_type(KeyType), help='specifies Primary or Secondary key needs to be reset')
    keyvalue_arg_type = CLIArgumentType(options_list=['--key-value'], help='Optional, if the key value provided, is set for KeyType or autogenerated Key value set for keyType.')

    with self.argument_context('servicebus') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('namespace_name', options_list=['--namespace-name'], id_part='name', help='Name of Namespace')

    with self.argument_context('servicebus namespace') as c:
        c.argument('namespace_name', id_part='name', arg_type=name_type, completer=get_resource_name_completion_list('Microsoft.ServiceBus/namespaces'), help='Name of Namespace')

    with self.argument_context('servicebus namespace exists') as c:
        c.argument('name', arg_type=name_type, help='Namespace name. Name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number.')

    for scope in ['servicebus namespace create', 'servicebus namespace update']:
        with self.argument_context(scope) as c:
            c.argument('tags', arg_type=tags_type)
            c.argument('sku', arg_type=get_enum_type(SkuName))
            c.argument('capacity', type=int, choices=[1, 2, 4], help='Number of message units. This property is only applicable to namespaces of Premium SKU', validator=validate_premiumsku_capacity)

    with self.argument_context('servicebus namespace create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)

    # region Namespace Authorization Rule
    with self.argument_context('servicebus namespace authorization-rule list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')

    with self.argument_context('servicebus namespace authorization-rule') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_1', help='Name of Namespace Authorization Rule')
        c.argument('namespace_name', id_part='name', options_list=['--namespace-name'], help='Name of Namespace')

    for scope in ['servicebus namespace authorization-rule create', 'servicebus namespace authorization-rule update', 'servicebus queue authorization-rule create', 'servicebus queue authorization-rule update', 'servicebus topic authorization-rule create', 'servicebus topic authorization-rule update']:
        with self.argument_context(scope) as c:
            c.argument('rights', arg_type=rights_arg_type)

    with self.argument_context('servicebus namespace authorization-rule keys renew') as c:
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)

    with self.argument_context('servicebus namespace authorization-rule keys list') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='Name of Namespace Authorization Rule')
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')

    # region Queue
    with self.argument_context('servicebus queue') as c:
        c.argument('queue_name', arg_type=name_type, id_part='child_name_1', completer=get_queue_command_completion_list, help='Name of Queue')

    # region - Queue Create
    for scope in ['create', 'update']:
        with self.argument_context('servicebus queue {}'.format(scope)) as c:
            c.argument('queue_name', arg_type=name_type, id_part='child_name_1', help='Name of Queue')
            c.argument('lock_duration', validator=_validate_lock_duration, help='String ISO 8601 timespan or duration format for duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute.')
            c.argument('max_size_in_megabytes', options_list=['--max-size'], type=int, choices=[1024, 2048, 3072, 4096, 5120], help='The maximum size of queue in megabytes, which is the size of memory allocated for the queue. Default is 1024.')
            c.argument('requires_duplicate_detection', options_list=['--enable-duplicate-detection'], arg_type=get_three_state_flag(), help='A boolean value indicating if this queue requires duplicate detection.')
            c.argument('requires_session', options_list=['--enable-session'], arg_type=get_three_state_flag(), help='A boolean value indicating whether the queue supports the concept of sessions.')
            c.argument('default_message_time_to_live', validator=_validate_default_message_time_to_live, help='ISO 8601 timespan or duration time format for default message to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.')
            c.argument('dead_lettering_on_message_expiration', options_list=['--enable-dead-lettering-on-message-expiration'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether this queue has dead letter support when a message expires.')
            c.argument('duplicate_detection_history_time_window', validator=_validate_duplicate_detection_history_time_window, help='ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes.')
            c.argument('max_delivery_count', type=int, help='The maximum delivery count. A message is automatically deadlettered after this number of deliveries. default value is 10.')
            c.argument('status', arg_type=get_enum_type(['Active', 'Disabled', 'SendDisabled', 'ReceiveDisabled']), help='Enumerates the possible values for the status of a messaging entity.')
            c.argument('auto_delete_on_idle', validator=_validate_auto_delete_on_idle, help='ISO 8601 timeSpan or duration time format for idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes.')
            c.argument('enable_partitioning', arg_type=get_three_state_flag(), help='A boolean value that indicates whether the queue is to be partitioned across multiple message brokers.')
            c.argument('enable_express', arg_type=get_three_state_flag(), help='A boolean value that indicates whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing it to persistent storage.')
            c.argument('forward_to', help='Queue/Topic name to forward the messages')
            c.argument('forward_dead_lettered_messages_to', help='Queue/Topic name to forward the Dead Letter message')
            c.argument('enable_batched_operations', arg_type=get_three_state_flag(), help='Allow server-side batched operations.')

    with self.argument_context('servicebus queue list') as c:
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')

    # region Queue Authorization Rule
    with self.argument_context('servicebus queue authorization-rule') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='Name of Queue Authorization Rule')
        c.argument('queue_name', id_part='child_name_1', options_list=['--queue-name'], help='Name of Queue')

    with self.argument_context('servicebus queue authorization-rule list') as c:
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')
        c.argument('queue_name', id_part=None, options_list=['--queue-name'], help='Name of Queue')

    with self.argument_context('servicebus queue authorization-rule keys renew') as c:
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)

    with self.argument_context('servicebus queue authorization-rule keys list') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='Name of Queue Authorization Rule')
        c.argument('queue_name', id_part=None, options_list=['--queue-name'], help='Name of Queue')
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')

    # region - Topic
    for scope in ['servicebus topic show', 'servicebus topic delete']:
        with self.argument_context(scope) as c:
            c.argument('topic_name', arg_type=name_type, id_part='child_name_1', completer=get_topic_command_completion_list, help='Name of Topic')

    # region - Topic Create
    for scope in ['create', 'update']:
        with self.argument_context('servicebus topic {}'.format(scope)) as c:
            c.argument('topic_name', arg_type=name_type, id_part='child_name_1', completer=get_topic_command_completion_list, help='Name of Topic')
            c.argument('default_message_time_to_live', validator=_validate_default_message_time_to_live, help='ISO 8601 or duration time format for Default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.')
            c.argument('max_size_in_megabytes', options_list=['--max-size'], type=int, choices=[1024, 2048, 3072, 4096, 5120], help='Maximum size of topic in megabytes, which is the size of the memory allocated for the topic. Default is 1024.')
            c.argument('requires_duplicate_detection', options_list=['--enable-duplicate-detection'], arg_type=get_three_state_flag(), help='A boolean value indicating if this topic requires duplicate detection.')
            c.argument('duplicate_detection_history_time_window', validator=_validate_duplicate_detection_history_time_window, help='ISO 8601 timespan or duration time format for structure that defines the duration of the duplicate detection history. The default value is 10 minutes.')
            c.argument('enable_batched_operations', arg_type=get_three_state_flag(), help='Allow server-side batched operations.')
            c.argument('status', arg_type=get_enum_type(['Active', 'Disabled', 'SendDisabled', 'ReceiveDisabled']), help='Enumerates the possible values for the status of a messaging entity.')
            c.argument('support_ordering', options_list=['--enable-ordering'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether the topic supports ordering.')
            c.argument('auto_delete_on_idle', validator=_validate_auto_delete_on_idle, help='ISO 8601 timespan or duration time format for idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes.')
            c.argument('enable_partitioning', arg_type=get_three_state_flag(), help='A boolean value that indicates whether the topic to be partitioned across multiple message brokers is enabled.')
            c.argument('enable_express', arg_type=get_three_state_flag(), help='A boolean value that indicates whether Express Entities are enabled. An express topic holds a message in memory temporarily before writing it to persistent storage.')

    for scope in ['servicebus topic show', 'servicebus topic delete']:
        with self.argument_context(scope) as c:
            c.argument('topic_name', arg_type=name_type, id_part='child_name_1', completer=get_topic_command_completion_list, help='Name of Topic')

    with self.argument_context('servicebus topic list') as c:
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')

    # region Topic Authorization Rule
    with self.argument_context('servicebus topic authorization-rule') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='name of Topic Authorization Rule')
        c.argument('topic_name', options_list=['--topic-name'], id_part='child_name_1', help='name of Topic')

    with self.argument_context('servicebus topic authorization-rule list') as c:
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')
        c.argument('topic_name', options_list=['--topic-name'], id_part=None, help='name of Topic')

    with self.argument_context('servicebus topic authorization-rule keys renew') as c:
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)

    with self.argument_context('servicebus topic authorization-rule keys list') as c:
        c.argument('namespace_name', id_part=None, options_list=['--namespace-name'], help='Name of Namespace')
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='name of Topic Authorization Rule')
        c.argument('topic_name', options_list=['--topic-name'], id_part=None, help='Name of Topic')

    with self.argument_context('servicebus topic subscription') as c:
        c.argument('subscription_name', arg_type=name_type, id_part='child_name_2', completer=get_subscriptions_command_completion_list, help='Name of Subscription')
        c.argument('topic_name', id_part='child_name_1', options_list=['--topic-name'], help='Name of Topic')

    # region - Subscription Create and update
    for scope in ['create', 'update']:
        with self.argument_context('servicebus topic subscription {}'.format(scope)) as c:
            c.argument('lock_duration', validator=_validate_lock_duration, help='ISO 8601 or duration format (day:minute:seconds) for lock duration timespan for the subscription. The default value is 1 minute.')
            c.argument('requires_session', options_list=['--enable-session'], arg_type=get_three_state_flag(), help='A boolean value indicating if a subscription supports the concept of sessions.')
            c.argument('default_message_time_to_live', validator=_validate_default_message_time_to_live, help='ISO 8601 or duration time format for Default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.')
            c.argument('dead_lettering_on_message_expiration', options_list=['--enable-dead-lettering-on-message-expiration'], arg_type=get_three_state_flag(), help='A boolean Value that indicates whether a subscription has dead letter support when a message expires.')
            c.argument('max_delivery_count', type=int, help='Number of maximum deliveries.')
            c.argument('status', arg_type=get_enum_type(['Active', 'Disabled', 'SendDisabled', 'ReceiveDisabled']))
            c.argument('enable_batched_operations', arg_type=get_three_state_flag(), help='Allow server-side batched operations.')
            c.argument('auto_delete_on_idle', validator=_validate_auto_delete_on_idle, options_list=['--auto-delete-on-idle'], help='ISO 8601 timeSpan  or duration time format for idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes.')
            c.argument('forward_to', help='Queue/Topic name to forward the messages')
            c.argument('forward_dead_lettered_messages_to', help='Queue/Topic name to forward the Dead Letter message')
            c.argument('dead_lettering_on_filter_evaluation_exceptions', options_list=['--dead-letter-on-filter-exceptions'], arg_type=get_three_state_flag(), help='Allow dead lettering when filter evaluation exceptions occur.')

    with self.argument_context('servicebus topic subscription list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('topic_name', options_list=['--topic-name'], id_part=None, help='Name of Topic')

    # Region Subscription Rules
    # Rules Create

    with self.argument_context('servicebus topic subscription rule') as c:
        c.argument('rule_name', arg_type=name_type, id_part='child_name_3', completer=get_rules_command_completion_list, help='Name of Rule')
        c.argument('subscription_name', options_list=['--subscription-name'], id_part='child_name_2', help='Name of Subscription')
        c.argument('topic_name', options_list=['--topic-name'], id_part='child_name_1', help='Name of Topic')

    for scope in ['servicebus topic subscription rule create', 'servicebus topic subscription rule update']:
        with self.argument_context(scope, arg_group='Action') as c:
            c.argument('filter_type', arg_type=get_enum_type(FilterType), help='Rule Filter types')
            c.argument('action_sql_expression', help='Action SQL expression.')
            c.argument('action_compatibility_level', type=int, help='This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20.')
            c.argument('action_requires_preprocessing', options_list=['--enable-action-preprocessing'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether the rule action requires preprocessing.')
        with self.argument_context(scope, arg_group='SQL Filter') as c:
            c.argument('filter_sql_expression', help='SQL expression. e.g. myproperty=test')
            c.argument('filter_requires_preprocessing', options_list=['--enable-sql-preprocessing'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether the rule action requires preprocessing.')
        with self.argument_context(scope, arg_group='Correlation Filter') as c:
            c.argument('correlation_id', help='Identifier of correlation.')
            c.argument('message_id', help='Identifier of message.')
            c.argument('to', help='Address to send to.')
            c.argument('reply_to', help='Address of the queue to reply to.')
            c.argument('label', help='Application specific label.')
            c.argument('session_id', help='Session identifier')
            c.argument('reply_to_session_id', help='Session identifier to reply to.')
            c.argument('content_type', help='Content type of message.')
            c.argument('requires_preprocessing', options_list=['--enable-correlation-preprocessing'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether the rule action requires preprocessing.')

    with self.argument_context('servicebus topic subscription rule list') as c:
        c.argument('subscription_name', options_list=['--subscription-name'], id_part=None, help='Name of Subscription')
        c.argument('topic_name', options_list=['--topic-name'], id_part=None, help='Name of Topic')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    # Geo DR - Disaster Recovery Configs - Alias  : Region
    with self.argument_context('servicebus georecovery-alias exists') as c:
        c.argument('name', options_list=['--alias', '-a'], arg_type=name_type, help='Name of Geo-Disaster Recovery Configuration Alias to check availability')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('servicebus georecovery-alias') as c:
        c.argument('alias', options_list=['--alias', '-a'], id_part='child_name_1', help='Name of the Geo-Disaster Recovery Configuration Alias')

    with self.argument_context('servicebus georecovery-alias set') as c:
        c.argument('partner_namespace', required=True, options_list=['--partner-namespace'], validator=validate_partner_namespace, help='Name (if within the same resource group) or ARM Id of Primary/Secondary Service Bus  namespace name, which is part of GEO DR pairing')
        c.argument('alternate_name', help='Alternate Name (Post failover) for Primary Namespace, when Namespace name and Alias name are same')

    for scope in ['servicebus georecovery-alias authorization-rule show', 'servicebus georecovery-alias authorization-rule keys list']:
        with self.argument_context(scope)as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='name of Namespace Authorization Rule')

    with self.argument_context('servicebus georecovery-alias list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('servicebus georecovery-alias authorization-rule list') as c:
        c.argument('alias', options_list=['--alias', '-a'], help='Name of Geo-Disaster Recovery Configuration Alias')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('servicebus georecovery-alias authorization-rule keys list') as c:
        c.argument('alias', options_list=['--alias', '-a'], id_part=None, help='Name of Geo-Disaster Recovery Configuration Alias')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('authorization_rule_name', arg_type=name_type, help='Name of Namespace AuthorizationRule')

    # Standard to Premium Migration: Region

    with self.argument_context('servicebus migration start') as c:
        c.argument('namespace_name', arg_type=name_type, help='Name of Standard Namespace used as source of the migration')
        c.argument('target_namespace', options_list=['--target-namespace'], validator=validate_target_namespace, help='Name (if within the same resource group) or ARM Id of empty Premium Service Bus namespace name that will be target of the migration')
        c.argument('post_migration_name', options_list=['--post-migration-name'], help='Post migration name is the name that can be used to connect to standard namespace after migration is complete.')

    for scope in ['show', 'complete', 'abort']:
        with self.argument_context('servicebus migration {}'.format(scope)) as c:
            c.argument('namespace_name', arg_type=name_type, help='Name of Standard Namespace')
示例#20
0
def load_arguments(self, _):

    from azext_front_door.vendored_sdks.models import (
        Mode, FrontDoorProtocol, FrontDoorCertificateSource, FrontDoorQuery, RuleGroupOverride, Action, RuleType, Transform,
        FrontDoorRedirectType, FrontDoorRedirectProtocol
    )

    frontdoor_name_type = CLIArgumentType(options_list=['--front-door-name', '-f'], help='Name of the Front Door.', completer=get_resource_name_completion_list('Microsoft.Network/frontdoors'), id_part='name')
    waf_policy_name_type = CLIArgumentType(options_list='--policy-name', help='Name of the WAF policy.', completer=get_resource_name_completion_list('Microsoft.Network/frontDoorWebApplicationFirewallPolicies'), id_part='name')

    # region FrontDoors
    fd_subresources = [
        {'name': 'backend-pool', 'display': 'backend pool', 'ref': 'backend_pools'},
        {'name': 'frontend-endpoint', 'display': 'frontend endpoint', 'ref': 'frontend_endpoints'},
        {'name': 'load-balancing', 'display': 'load balancing settings', 'ref': 'load_balancing_settings'},
        {'name': 'probe', 'display': 'health probe', 'ref': 'health_probe_settings'},
        {'name': 'routing-rule', 'display': 'routing rule', 'ref': 'routing_rules'}
    ]
    for item in fd_subresources:
        with self.argument_context('network front-door {}'.format(item['name'])) as c:
            c.argument('item_name', options_list=['--name', '-n'], help='Name of the {}'.format(item['display']), completer=get_fd_subresource_completion_list(item['ref']), id_part='child_name_1')
            c.argument('front_door_name', frontdoor_name_type, id_part=None)
            c.argument('resource_name', frontdoor_name_type, id_part=None)

    with self.argument_context('network front-door') as c:
        c.argument('front_door_name', frontdoor_name_type, options_list=['--name', '-n'])
        c.argument('friendly_name', help='Friendly name of the Front Door.')
        c.argument('tags', tags_type)
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create in a disabled state.')
        c.argument('enabled', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Enabled status.')

    with self.argument_context('network front-door', arg_group='Frontend Endpoint') as c:
        c.argument('frontend_host_name', help='Domain name of the frontend endpoint.')

    with self.argument_context('network front-door', arg_group='HTTPS') as c:
        c.argument('certificate_source', arg_type=get_enum_type(FrontDoorCertificateSource), help='Certificate source to enable HTTPS.')
        c.argument('secret_name', help='The name of the Key Vault secret representing the full certificate PFX')
        c.argument('secret_version', help='The version of the Key Vault secret representing the full certificate PFX')
        c.argument('vault_id', help='The resource id of the Key Vault containing the SSL certificate')

    with self.argument_context('network front-door', arg_group='BackendPools Settings') as c:
        c.argument('enforce_certificate_name_check', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Whether to disable certificate name check on HTTPS requests to all backend pools. No effect on non-HTTPS requests.')

    with self.argument_context('network front-door', arg_group='Backend') as c:
        c.argument('backend_address', help='FQDN of the backend endpoint.')
        c.argument('backend_host_header', help='Host header sent to the backend.')

    with self.argument_context('network front-door', arg_group='Probe Setting') as c:
        c.argument('probe_path', options_list='--path', help='Path to probe.')
        c.argument('probe_protocol', options_list='--protocol', arg_type=get_enum_type(FrontDoorProtocol), help='Protocol to use for sending probes.')
        c.argument('probe_interval', options_list='--interval', help='Interval in seconds between probes.')

    with self.argument_context('network front-door', arg_group='Routing Rule') as c:
        c.argument('accepted_protocols', nargs='+', help='Space-separated list of protocols to accept. Default: Http')
        c.argument('patterns_to_match', options_list='--patterns', nargs='+', help='Space-separated list of patterns to match. Default: \'/*\'.')
        c.argument('forwarding_protocol', help='Protocol to use for forwarding traffic.')
        c.argument('route_type', arg_type=get_enum_type(RouteType), help='Route type to define how Front Door should handle requests for this route i.e. forward them to a backend or redirect the users to a different URL.')

    with self.argument_context('network front-door purge-endpoint') as c:
        c.argument('content_paths', nargs='+')

    with self.argument_context('network front-door backend-pool') as c:
        c.argument('load_balancing_settings', options_list='--load-balancing', help='Name or ID of the load balancing settings.', validator=validate_load_balancing_settings)
        c.argument('probe_settings', options_list='--probe', help='Name or ID of the probe settings.', validator=validate_probe_settings)

    with self.argument_context('network front-door frontend-endpoint') as c:
        c.argument('host_name', help='Domain name of the frontend endpoint.')
        c.argument('session_affinity_enabled', arg_type=get_three_state_flag(), help='Whether to allow session affinity on this host.')
        c.argument('session_affinity_ttl', help='The TTL to use in seconds for session affinity.', type=int)
        c.argument('waf_policy', help='Name or ID of a web application firewall policy.', validator=validate_waf_policy)

    with self.argument_context('network front-door load-balancing') as c:
        c.argument('additional_latency', type=int, help='The additional latency in milliseconds for probes to fall in the lowest latency bucket.')
        c.argument('sample_size', type=int, help='The number of samples to consider for load balancing decisions.')
        c.argument('successful_samples_required', type=int, help='The number of samples within the sample period that must succeed.')

    with self.argument_context('network front-door probe') as c:
        c.argument('path', help='Path to probe.')
        c.argument('protocol', arg_type=get_enum_type(FrontDoorProtocol), help='Protocol to use for sending probes.')
        c.argument('interval', help='Interval in seconds between probes.')

    for scope in ['backend-pool', 'backend-pool backend']:
        arg_group = 'Backend' if scope == 'backend-pool' else None
        with self.argument_context('network front-door {}'.format(scope), arg_group=arg_group) as c:
            c.argument('address', help='FQDN of the backend endpoint.')
            c.argument('host_header', help='Host header sent to the backend.')
            c.argument('priority', type=int, help='Priority to use for load balancing. Higher priorities will not be used for load balancing if any lower priority backend is healthy.')
            c.argument('http_port', type=int, help='HTTP TCP port number.')
            c.argument('https_port', type=int, help='HTTPS TCP port number.')
            c.argument('weight', type=int, help='Weight of this endpoint for load balancing purposes.')
            c.argument('backend_host_header', help='Host header sent to the backend.')
            c.argument('backend_pool_name', options_list='--pool-name', help='Name of the backend pool.')
            c.argument('index', type=int, help='Index of the backend to remove (starting with 1).')

    with self.argument_context('network front-door routing-rule', arg_group=None) as c:
        c.argument('accepted_protocols', nargs='+', help='Space-separated list of protocols to accept. Default: Http')
        c.argument('patterns_to_match', options_list='--patterns', nargs='+', help='Space-separated list of patterns to match. Default: \'/*\'.')
        c.argument('forwarding_protocol', help='Protocol to use for forwarding traffic.')
        c.argument('backend_pool', help='Name or ID of a backend pool.', validator=validate_backend_pool)
        c.argument('frontend_endpoints', help='Space-separated list of frontend endpoint names or IDs.', nargs='+', validator=validate_frontend_endpoints)
        c.argument('custom_forwarding_path', help='Custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path.')
        c.argument('dynamic_compression', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Use dynamic compression for cached content.')
        c.argument('query_parameter_strip_directive', arg_type=get_enum_type(FrontDoorQuery), help='Treatment of URL query terms when forming the cache key.')
        c.argument('redirect_type', arg_type=get_enum_type(FrontDoorRedirectType), help='The redirect type the rule will use when redirecting traffic.')
        c.argument('redirect_protocol', arg_type=get_enum_type(FrontDoorRedirectProtocol), help='The protocol of the destination to where the traffic is redirected.')
        c.argument('custom_host', help='Host to redirect. Leave empty to use use the incoming host as the destination host.')
        c.argument('custom_path', help='The full path to redirect. Path cannot be empty and must start with /. Leave empty to use the incoming path as destination path.')
        c.argument('custom_fragment', help='Fragment to add to the redirect URL. Fragment is the part of the URL that comes after #. Do not include the #.')
        c.argument('custom_query_string', help='The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the incoming query string. Query string must be in <key>=<value> format. The first ? and & will be added automatically so do not include them in the front, but do separate multiple query strings with &.')
    # endregion

    # region WafPolicy
    with self.argument_context('network waf-policy') as c:
        c.argument('tags', tags_type)
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create in a disabled state.')
        c.argument('enabled', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Enabled status.')
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('mode', arg_type=get_enum_type(Mode), help='Firewall policy mode.')
        c.argument('policy_name', waf_policy_name_type, options_list=['--name', '-n'])

    with self.argument_context('network waf-policy set-managed-ruleset') as c:
        c.argument('action', arg_type=get_enum_type(Action), help='Action for overriden rulesets.')
        c.argument('override', arg_type=get_enum_type(RuleGroupOverride), help='Name of the ruleset to override.')
        c.argument('priority', type=int, help='Rule priority.')
        c.argument('version', help='Rule set version.')
        c.argument('disable', help='Disable managed ruleset override.', action='store_true')

    with self.argument_context('network waf-policy custom-rule') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)
        c.argument('priority', type=int, help='Priority of the rule.')
        c.argument('rate_limit_duration', type=int, help='Rate limit duration in minutes.')
        c.argument('rate_limit_threshold', type=int, help='Rate limit threshold.')
        c.argument('rule_type', arg_type=get_enum_type(RuleType), help='Type of rule.')
        c.argument('action', arg_type=get_enum_type(Action), help='Rule action.')
        c.argument('transforms', nargs='+', arg_type=get_enum_type(Transform), help='Space-separated list of transforms to apply.')
        c.argument('match_conditions', nargs='+', options_list='--match-condition', action=MatchConditionAction)

    with self.argument_context('network waf-policy custom-rule list') as c:
        c.argument('policy_name', waf_policy_name_type, id_part=None)
示例#21
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 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)

    # 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.')

    _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('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('subscription', arg_type=subscription_type)
        c.argument('management_group', arg_type=management_group_name_type)

    with self.argument_context('policy definition create', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as c:
        from azure.mgmt.resource.policy.models import PolicyMode
        c.argument('name', options_list=['--name', '-n'], help='Name of the new policy definition.')
        c.argument('mode', arg_type=get_enum_type(PolicyMode), options_list=['--mode', '-m'], help='Mode of the new policy definition.', min_api='2016-12-01')

    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 path to file with parameter values of policy rule.', 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 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('subscription', arg_type=subscription_type)
        c.argument('management_group', arg_type=management_group_name_type)

    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', options_list=['--name', '-n'], required=True, help='The deployment name.')
        c.argument('template_file', completer=FilesCompleter(), type=file_type, help="a template file path in the file system")
        c.argument('template_uri', help='a uri to a remote template file')
        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', action='append', nargs='+', completer=FilesCompleter())
        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', options_list=['--name', '-n'], required=False,
                   help='The deployment name. Default to template file base name')

    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', options_list=['--name', '-n'], required=True, help='The deployment name.')
        c.argument('deployment_location', arg_type=get_location_type(self.cli_ctx), required=True)
        c.argument('template_file', completer=FilesCompleter(), type=file_type, help="a template file path in the file system")
        c.argument('template_uri', help='a uri to a remote template file')
        c.argument('parameters', action='append', nargs='+', completer=FilesCompleter())

    with self.argument_context('deployment create') as c:
        c.argument('deployment_name', options_list=['--name', '-n'], required=False,
                   help='The deployment name. Default to template file base name')

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

    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)

    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'])
        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]))
            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))
        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)

    with self.argument_context('account management-group') as c:
        c.argument('group_name', options_list=['--name', '-n'])
        c.ignore('_subscription')  # hide global subscription parameter

    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'])
示例#22
0
def load_arguments(self, _):

    ExpressRoutePortsEncapsulation, ExpressRouteCircuitSkuFamily, ExpressRouteCircuitSkuTier = self.get_models(
        'ExpressRoutePortsEncapsulation', 'ExpressRouteCircuitSkuFamily', 'ExpressRouteCircuitSkuTier')

    er_circuit_name_type = CLIArgumentType(options_list=('--circuit-name',), metavar='NAME', help='ExpressRoute circuit name.', id_part='name', completer=get_resource_name_completion_list('Microsoft.Network/expressRouteCircuits'))
    er_gateway_name_type = CLIArgumentType(options_list=('--gateway-name',), metavar='NAME', help='ExpressRoute gateway name.', id_part='name', completer=get_resource_name_completion_list('Microsoft.Network/expressRouteGateways'))
    er_port_name_type = CLIArgumentType(options_list=('--port-name',), metavar='NAME', help='ExpressRoute port name.', id_part='name', completer=get_resource_name_completion_list('Microsoft.Network/expressRoutePorts'))
    er_bandwidth_type = CLIArgumentType(options_list='--bandwidth', nargs='+')

    with self.argument_context('network express-route') as c:
        c.argument('tags', tags_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)

    with self.argument_context('network express-route gateway') as c:
        c.argument('express_route_gateway_name', er_gateway_name_type, options_list=['--name', '-n'])
        c.argument('min_val', help='Minimum number of scale units deployed for gateway.', type=int, arg_group='Autoscale')
        c.argument('max_val', help='Maximum number of scale units deployed for gateway.', type=int, arg_group='Autoscale')
        c.argument('virtual_hub', help='Name or ID of the virtual hub to associate with the gateway.', validator=validate_virtual_hub)

    with self.argument_context('network express-route gateway connection') as c:
        c.argument('express_route_gateway_name', er_gateway_name_type)
        c.argument('connection_name', options_list=['--name', '-n'], help='ExpressRoute connection name.', id_part='child_name_1')
        c.argument('routing_weight', help='Routing weight associated with the connection.', type=int)
        c.argument('authorization_key', help='Authorization key to establish the connection.')

    with self.argument_context('network express-route gateway connection', arg_group='Peering') as c:
        c.argument('peering', help='Name or ID of an ExpressRoute peering.', validator=validate_express_route_peering)
        c.argument('circuit_name', er_circuit_name_type, id_part=None)

    with self.argument_context('network express-route gateway connection list') as c:
        c.argument('express_route_gateway_name', er_gateway_name_type, id_part=None)

    with self.argument_context('network express-route port') as c:
        c.argument('express_route_port_name', er_port_name_type, options_list=['--name', '-n'])
        c.argument('encapsulation', arg_type=get_enum_type(ExpressRoutePortsEncapsulation), help='Encapsulation method on physical ports.')
        c.argument('bandwidth_in_gbps', er_bandwidth_type, validator=bandwidth_validator_factory(mbps=False),
                   help='Bandwidth of the circuit. Usage: INT {Mbps,Gbps}. Defaults to Gbps')
        c.argument('peering_location', help='The name of the peering location that the port is mapped to physically.')

    with self.argument_context('network express-route port link') as c:
        c.argument('express_route_port_name', er_port_name_type)
        c.argument('link_name', options_list=['--name', '-n'], id_part='child_name_1')

    with self.argument_context('network express-route port link list') as c:
        c.argument('express_route_port_name', er_port_name_type, id_part=None)

    with self.argument_context('network express-route port location') as c:
        c.argument('location_name', options_list=['--location', '-l'])

    # region ExpressRoutes
    device_path_values = ['primary', 'secondary']
    sku_family_type = CLIArgumentType(help='Chosen SKU family of ExpressRoute circuit.', arg_type=get_enum_type(ExpressRouteCircuitSkuFamily), default=ExpressRouteCircuitSkuFamily.metered_data.value)
    sku_tier_type = CLIArgumentType(help='SKU Tier of ExpressRoute circuit.', arg_type=get_enum_type(ExpressRouteCircuitSkuTier), default=ExpressRouteCircuitSkuTier.standard.value)
    with self.argument_context('network express-route') as c:
        c.argument('circuit_name', er_circuit_name_type, options_list=('--name', '-n'))
        c.argument('sku_family', sku_family_type)
        c.argument('sku_tier', sku_tier_type)
        c.argument('bandwidth_in_mbps', er_bandwidth_type, validator=bandwidth_validator_factory(mbps=True),
                   help='Bandwidth of the circuit. Usage: INT {Mbps,Gbps}. Defaults to Mbps')
        c.argument('service_provider_name', options_list=('--provider',), help="Name of the ExpressRoute Service Provider.")
        c.argument('peering_location', help="Name of the peering location.")
        c.argument('device_path', options_list=('--path',), arg_type=get_enum_type(device_path_values))
        c.argument('vlan_id', type=int)
        c.argument('allow_global_reach', arg_type=get_three_state_flag(), min_api='2018-07-01', help='Enable global reach on the circuit.')

    with self.argument_context('network express-route') as c:
        c.argument('express_route_port', help='Name or ID of an ExpressRoute port.', validator=validate_express_route_port)

    with self.argument_context('network express-route update') as c:
        c.argument('sku_family', sku_family_type, default=None)
        c.argument('sku_tier', sku_tier_type, default=None)
示例#23
0
def load_arguments(self, _):

    for scope in ['sql vm', 'sql vm group']:
        with self.argument_context(scope) as c:
            c.argument('tags', tags_type)

    ###############################################
    #    sql virtual machine groups params        #
    ###############################################

    with self.argument_context('sql vm group') as c:
        c.argument('sql_virtual_machine_group_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='Name of the SQL virtual machine group.')
        c.argument('sql_image_offer',
                   options_list=['--image-offer', '-i'],
                   help='SQL image offer. Examples may include SQL2016-WS2016, SQL2017-WS2016.')
        c.argument('sql_image_sku',
                   options_list=['--image-sku', '-s'],
                   help='SQL image sku.',
                   arg_type=get_enum_type(SqlVmGroupImageSku))
        c.argument('location',
                   help='Location. If not provided, group will be created in the same reosurce group location.'
                   'You can configure the default location using `az configure --defaults location=<location>`.',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)

    with self.argument_context('sql vm group', arg_group='WSFC Domain Profile') as c:
        c.argument('domain_fqdn',
                   options_list=['--domain-fqdn', '-f'],
                   help='Fully qualified name of the domain.')
        c.argument('cluster_operator_account',
                   options_list=['--operator-acc', '-p'],
                   help='Account name used for operating cluster i.e. will be part of administrators group on all the participating virtual machines in the cluster.')
        c.argument('sql_service_account',
                   options_list=['--service-acc', '-e'],
                   help='Account name under which SQL service will run on all participating SQL virtual machines in the cluster.')
        c.argument('storage_account_url',
                   options_list=['--storage-account', '-u'],
                   help='Storage account url of the witness storage account.')
        c.argument('storage_account_key',
                   options_list=['--sa-key', '-k'],
                   help='Primary key of the witness storage account.')
        c.argument('cluster_bootstrap_account',
                   options_list=['--bootstrap-acc'],
                   help='Account name used for creating cluster (at minimum needs permissions to \'Create Computer Objects\' in domain).')
        c.argument('file_share_witness_path',
                   options_list=['--fsw-path'],
                   help='Optional path for fileshare witness.')
        c.argument('ou_path',
                   help='Organizational Unit path in which the nodes and cluster will be present. Example: OU=WSCluster,DC=testdomain,DC=com')

    ###############################################
    #    availability group listener params       #
    ###############################################

    with self.argument_context('sql vm group ag-listener') as c:
        c.argument('availability_group_listener_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='Name of the availability group listener.')
        c.argument('sql_virtual_machine_group_name',
                   options_list=['--group-name', '-r'],
                   help='Name of the SQL virtual machine group.',
                   id_part=None)
        c.argument('port',
                   options_list=['--port', '-p'],
                   help='Listener port.',
                   type=int)
        c.argument('availability_group_name',
                   options_list=['--ag-name', '-a'],
                   help='Name of the availability group. Please refer to '
                   'https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/use-the-availability-group-wizard-sql-server-management-studio?view=sql-server-2017 '
                   'to create and availability group')

    with self.argument_context('sql vm group ag-listener', arg_group='Load Balancer Configuration') as c:
        c.argument('ip_address',
                   options_list=['--ip-address', '-i'],
                   help='Private IP address bound to the availability group listener.')
        c.argument('subnet_resource_id',
                   options_list=['--subnet', '-u'],
                   validator=validate_subnet,
                   help='The name or resource id of the subnet to include in the private IP.')
        c.argument('vnet_name',
                   options_list=['--vnet-name'],
                   help='Name of the virtual network. Provide only if name of the subnet has been provided.')
        c.argument('public_ip_address_resource_id',
                   options_list=['--public-ip', '-c'],
                   validator=validate_public_ip_address,
                   help='Name or resource ID of the public IP.')
        c.argument('load_balancer_resource_id',
                   options_list=['--load-balancer', '-b'],
                   validator=validate_load_balancer,
                   help='Name or resource ID of the load balancer.')
        c.argument('probe_port',
                   options_list=['--probe-port', '-e'],
                   help='Probe port.',
                   type=int)
        c.argument('sql_virtual_machine_instances',
                   options_list=['--sqlvms', '-q'],
                   nargs='+',
                   validator=validate_sqlvm_list,
                   help='Space-separated list of SQL virtual machine instance name or resource IDs that are enrolled into the availability group.')

    ###############################################
    #      sql virtual machine params             #
    ###############################################

    with self.argument_context('sql vm') as c:
        c.argument('sql_virtual_machine_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='Name of the SQL virtual machine.')
        c.argument('location',
                   help='Location. If not provided, virtual machine should be in the same region of resource group.'
                   'You can configure the default location using `az configure --defaults location=<location>`.',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('expand',
                   help='Get the SQLIaaSExtension configuration settings.',
                   arg_type=get_enum_type(['*']))

    with self.argument_context('sql vm', arg_group='SQL Server License') as c:
        c.argument('sql_server_license_type',
                   help='SQL Server license type.',
                   options_list=['--license-type'],
                   arg_type=get_enum_type(SqlServerLicenseType))

    with self.argument_context('sql vm add-to-group') as c:
        c.argument('sql_virtual_machine_group_resource_id',
                   options_list=['--sqlvm-group', '-r'],
                   validator=validate_sqlvm_group,
                   help='Name or resource ID of the SQL virtual machine group. If only name provided, SQL virtual machine group should be in the same '
                   'resource group of the SQL virtual machine.')
        c.argument('sql_virtual_machine_name',
                   id_part='name',
                   help="Name of the SQL virtual machine.")

    with self.argument_context('sql vm remove-from-group') as c:
        c.argument('sql_virtual_machine_name',
                   id_part='name',
                   help="Name of the SQL virtual machine.")

    with self.argument_context('sql vm add-to-group', arg_group='WSFC Domain Credentials') as c:
        c.argument('cluster_bootstrap_account_password',
                   options_list=['-b', '--bootstrap-acc-pwd',
                                 c.deprecate(target='--boostrap-acc-pwd', redirect='--bootstrap-acc-pwd')],
                   help='Password for the cluster bootstrap account if provided in the SQL virtual machine group.')
        c.argument('cluster_operator_account_password',
                   options_list=['--operator-acc-pwd', '-p'],
                   help='Password for the cluster operator account provided in the SQL virtual machine group.')
        c.argument('sql_service_account_password',
                   options_list=['--service-acc-pwd', '-s'],
                   help='Password for the SQL service account provided in the SQL virtual machine group.')

    with self.argument_context('sql vm', arg_group='Auto Patching Settings') as c:
        c.argument('enable_auto_patching',
                   help='Enable or disable autopatching on SQL virtual machine. If any autopatching settings provided, parameter automatically sets to true.',
                   arg_type=get_three_state_flag())
        c.argument('day_of_week',
                   help='Day of week to apply the patch on.',
                   arg_type=get_enum_type(DayOfWeek))
        c.argument('maintenance_window_starting_hour',
                   type=int,
                   options_list=['--maintenance-window-start-hour'],
                   help='Hour of the day when patching is initiated. Local VM time 0-23 hours.')
        c.argument('maintenance_window_duration',
                   type=int,
                   help='Duration of patching. 30-180 minutes.')

    with self.argument_context('sql vm', arg_group='Auto Backup Settings') as c:
        c.argument('enable_auto_backup',
                   help='Enable or disable autobackup on SQL virtual machine. If any backup settings provided, parameter automatically sets to true.',
                   arg_type=get_three_state_flag())
        c.argument('enable_encryption',
                   help=' Enable encryption for backup on SQL virtual machine.',
                   arg_type=get_three_state_flag())
        c.argument('retention_period',
                   type=int,
                   help='Retention period of backup. 1-30 days.')
        c.argument('storage_account_url',
                   options_list=['--storage-account'],
                   help='Storage account url where backup will be taken to.')
        c.argument('storage_access_key',
                   options_list=['--sa-key'],
                   help='Storage account key where backup will be taken to.')
        c.argument('backup_password',
                   options_list=['--backup-pwd'],
                   help='Password for encryption on backup.')
        c.argument('backup_system_dbs',
                   help='Include system databases on backup.',
                   arg_type=get_three_state_flag())
        c.argument('backup_schedule_type',
                   help='Backup schedule type.',
                   arg_type=get_enum_type(BackupScheduleType))
        c.argument('full_backup_frequency',
                   help='Frequency of full backups. In both cases, full backups begin during the next scheduled time window.',
                   arg_type=get_enum_type(FullBackupFrequencyType))
        c.argument('full_backup_start_time',
                   type=int,
                   options_list=['--full-backup-start-hour'],
                   help='Start time of a given day during which full backups can take place. 0-23 hours.')
        c.argument('full_backup_window_hours',
                   type=int,
                   options_list=['--full-backup-duration'],
                   help='Duration of the time window of a given day during which full backups can take place. 1-23 hours.')
        c.argument('log_backup_frequency',
                   type=int,
                   help='Frequency of log backups. 5-60 minutes.')

    with self.argument_context('sql vm', arg_group='Key Vault Credential Settings') as c:
        c.argument('enable_key_vault_credential',
                   help='Enable or disable key vault credential setting. If any key vault settings provided, parameter automatically sets to true.',
                   arg_type=get_three_state_flag())
        c.argument('credential_name',
                   help='Credential name')
        c.argument('azure_key_vault_url',
                   options_list=['--key-vault'],
                   help='Azure Key Vault url.')
        c.argument('service_principal_name',
                   options_list=['--sp-name'],
                   help='Service principal name to access key vault.')
        c.argument('service_principal_secret',
                   options_list=['--sp-secret'],
                   help='Service principal name secret to access key vault.')

    with self.argument_context('sql vm', arg_group='SQL Connectivity Update Settings') as c:
        c.argument('connectivity_type',
                   help='SQL Server connectivity option.',
                   arg_type=get_enum_type(ConnectivityType))
        c.argument('port',
                   help='SQL Server port.',
                   type=int)
        c.argument('sql_auth_update_username',
                   help='SQL Server sysadmin login to create.')
        c.argument('sql_auth_update_password',
                   options_list=['--sql-auth-update-pwd'],
                   help='SQL Server sysadmin login password.')

    with self.argument_context('sql vm', arg_group='SQL Workload Type Update Settings') as c:
        c.argument('sql_workload_type',
                   help='SQL Server workload type.',
                   arg_type=get_enum_type(SqlWorkloadType))

    with self.argument_context('sql vm', arg_group='SQL Storage Update Settings') as c:
        c.argument('disk_count',
                   help='Virtual machine disk count.',
                   type=int)
        c.argument('disk_configuration_type',
                   help='Disk configuration to apply to SQL Server.',
                   arg_type=get_enum_type(DiskConfigurationType))

    with self.argument_context('sql vm', arg_group='Additional Features') as c:
        c.argument('enable_r_services',
                   help='Enable or disable R services (SQL 2016 onwards).',
                   arg_type=get_three_state_flag())
示例#24
0
def load_arguments(self, _):
    from azure.mgmt.compute.models import CachingTypes, UpgradeMode
    from azure.mgmt.storage.models import SkuName

    # REUSABLE ARGUMENT DEFINITIONS
    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    multi_ids_type = CLIArgumentType(nargs='+')
    existing_vm_name = CLIArgumentType(overrides=name_arg_type,
                                       configured_default='vm',
                                       help="The name of the Virtual Machine. You can configure the default using `az configure --defaults vm=<name>`",
                                       completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines'), id_part='name')
    existing_disk_name = CLIArgumentType(overrides=name_arg_type, help='The name of the managed disk', completer=get_resource_name_completion_list('Microsoft.Compute/disks'), id_part='name')
    existing_snapshot_name = CLIArgumentType(overrides=name_arg_type, help='The name of the snapshot', completer=get_resource_name_completion_list('Microsoft.Compute/snapshots'), id_part='name')
    vmss_name_type = CLIArgumentType(name_arg_type,
                                     configured_default='vmss',
                                     completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'),
                                     help="Scale set name. You can configure the default using `az configure --defaults vmss=<name>`",
                                     id_part='name')
    disk_sku = CLIArgumentType(help='Underlying storage SKU.', arg_type=get_enum_type(['Premium_LRS', 'Standard_LRS']))

    # special case for `network nic scale-set list` command alias
    with self.argument_context('network nic scale-set list') as c:
        c.argument('virtual_machine_scale_set_name', options_list=['--vmss-name'], completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'), id_part='name')

    # region MixedScopes
    for scope in ['vm', 'disk', 'snapshot', 'image']:
        with self.argument_context(scope) as c:
            c.argument('tags', tags_type)

    for scope in ['disk', 'snapshot']:
        with self.argument_context(scope) as c:
            c.ignore('source_blob_uri', 'source_disk', 'source_snapshot')
            c.argument('source_storage_account_id', help='used when source blob is in a different subscription')
            c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB.')
            c.argument('duration_in_seconds', help='Time duration in seconds until the SAS access expires', type=int)

    for scope in ['disk create', 'snapshot create']:
        with self.argument_context(scope) as c:
            c.argument('source', help='source to create the disk/snapshot from, including unmanaged blob uri, managed disk id or name, or snapshot id or name')
    # endregion

    # region Disks
    with self.argument_context('disk') as c:
        c.argument('zone', zone_type, min_api='2017-03-30', options_list=['--zone'])  # TODO: --size-gb currently has claimed -z. We can do a breaking change later if we want to.
        c.argument('disk_name', existing_disk_name, completer=get_resource_name_completion_list('Microsoft.Compute/disks'))
        c.argument('name', arg_type=name_arg_type)
        c.argument('sku', arg_type=disk_sku)
    # endregion

    # region Identity
    # TODO move to its own command module https://github.com/Azure/azure-cli/issues/5105
    with self.argument_context('identity') as c:
        c.argument('resource_name', arg_type=name_arg_type, id_part='name')

    with self.argument_context('identity create') as c:
        c.argument('location', get_location_type(self.cli_ctx))
    # endregion

    # region Snapshots
    with self.argument_context('snapshot', resource_type=ResourceType.MGMT_COMPUTE, operation_group='snapshots') as c:
        c.argument('snapshot_name', existing_snapshot_name, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/snapshots'))
        c.argument('name', arg_type=name_arg_type)
        if self.supported_api_version(min_api='2018-04-01', operation_group='snapshots'):
            c.argument('sku', arg_type=get_enum_type(['Premium_LRS', 'Standard_LRS', 'Standard_ZRS']))
        else:
            c.argument('sku', arg_type=disk_sku)
    # endregion

    # region Images
    with self.argument_context('image') as c:
        c.argument('os_type', arg_type=get_enum_type(['Windows', 'Linux']))
        c.argument('image_name', arg_type=name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/images'))

    with self.argument_context('image create') as c:
        # here we collpase all difference image sources to under 2 common arguments --os-disk-source --data-disk-sources
        c.argument('name', arg_type=name_arg_type, help='new image name')
        c.argument('source', help='OS disk source from the same region, including a virtual machine ID or name, OS disk blob URI, managed OS disk ID or name, or OS snapshot ID or name')
        c.argument('data_disk_sources', nargs='+', help='Space-separated list of data disk sources, including unmanaged blob URI, managed disk ID or name, or snapshot ID or name')
        c.argument('zone_resilient', min_api='2017-12-01', arg_type=get_three_state_flag(), help='Specifies whether an image is zone resilient or not. '
                   'Default is false. Zone resilient images can be created only in regions that provide Zone Redundant Storage')
        c.ignore('source_virtual_machine', 'os_blob_uri', 'os_disk', 'os_snapshot', 'data_blob_uris', 'data_disks', 'data_snapshots')
    # endregion

    # region AvailabilitySets
    with self.argument_context('vm availability-set') as c:
        c.argument('availability_set_name', name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')

    with self.argument_context('vm availability-set create') as c:
        c.argument('availability_set_name', name_arg_type, validator=get_default_location_from_resource_group, help='Name of the availability set')
        c.argument('platform_update_domain_count', type=int, help='Update Domain count. If unspecified, server picks the most optimal number like 5. For the latest defaults see https://docs.microsoft.com/en-us/rest/api/compute/availabilitysets/availabilitysets-create')
        c.argument('platform_fault_domain_count', type=int, help='Fault Domain count.')
        c.argument('validate', help='Generate and validate the ARM template without creating any resources.', action='store_true')
        c.argument('unmanaged', action='store_true', min_api='2016-04-30-preview', help='contained VMs should use unmanaged disks')

    with self.argument_context('vm availability-set update') as c:
        if self.supported_api_version(max_api='2016-04-30-preview', operation_group='virtual_machines'):
            c.argument('name', name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')
            c.argument('availability_set_name', options_list=['--availability-set-name'])
    # endregion

    # region VirtualMachines
    with self.argument_context('vm') as c:
        c.argument('vm_name', existing_vm_name)
        c.argument('size', completer=get_vm_size_completion_list)
        c.argument('name', arg_type=name_arg_type)
        c.argument('zone', zone_type, min_api='2017-03-30')
        c.argument('caching', help='Disk caching policy', arg_type=get_enum_type(CachingTypes))
        c.argument('nsg', help='The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none.', arg_group='Network')
        c.argument('nsg_rule', help='NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux.', arg_group='Network', arg_type=get_enum_type(['RDP', 'SSH']))
        c.argument('application_security_groups', min_api='2017-09-01', nargs='+', options_list=['--asgs'], help='Space-separated list of existing application security groups to associate with the VM.', arg_group='Network')

    with self.argument_context('vm capture') as c:
        c.argument('overwrite', action='store_true')

    with self.argument_context('vm update') as c:
        c.argument('os_disk', min_api='2017-12-01', help="Managed OS disk ID or name to swap to. Feature registration for 'Microsoft.Compute/AllowManagedDisksReplaceOSDisk' is needed")
        c.argument('write_accelerator', nargs='*', min_api='2017-12-01',
                   help="enable/disable disk write accelerator. Use singular value 'true/false' to apply across, or specify individual disks, e.g.'os=true 1=true 2=true' for os disk and data disks with lun of 1 & 2")
        c.argument('disk_caching', nargs='*', help="Use singular value to apply across, or specify individual disks, e.g. 'os=ReadWrite 0=None 1=ReadOnly' should enable update os disk and 2 data disks")

    with self.argument_context('vm create') as c:
        c.argument('name', name_arg_type, validator=_resource_not_exists(self.cli_ctx, 'Microsoft.Compute/virtualMachines'))
        c.argument('vm_name', name_arg_type, id_part=None, help='Name of the virtual machine.', completer=None)
        c.argument('os_disk_size_gb', type=int, help='the size of the os disk in GB', arg_group='Storage')
        c.argument('attach_os_disk', help='Attach an existing OS disk to the VM. Can use the name or ID of a managed disk or the URI to an unmanaged disk VHD.')
        c.argument('attach_data_disks', nargs='+', help='Attach existing data disks to the VM. Can use the name or ID of a managed disk or the URI to an unmanaged disk VHD.')
        c.argument('availability_set', help='Name or ID of an existing availability set to add the VM to. None by default.')
        c.argument('nsg', help='The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none.', arg_group='Network')
        c.argument('nsg_rule', help='NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux.', arg_group='Network', arg_type=get_enum_type(['RDP', 'SSH']))
        c.argument('application_security_groups', resource_type=ResourceType.MGMT_NETWORK, min_api='2017-09-01', nargs='+', options_list=['--asgs'], help='Space-separated list of existing application security groups to associate with the VM.', arg_group='Network', validator=validate_asg_names_or_ids)
        c.argument('write_accelerator', nargs='*', min_api='2017-12-01', arg_group='Storage',
                   help="enable/disable disk write accelerator. Use singular value 'true/false' to apply across, or specify individual disks, e.g.'os=true 1=true 2=true' for os disk and data disks with lun of 1 & 2")

    with self.argument_context('vm open-port') as c:
        c.argument('vm_name', name_arg_type, help='The name of the virtual machine to open inbound traffic on.')
        c.argument('network_security_group_name', options_list=('--nsg-name',), help='The name of the network security group to create if one does not exist. Ignored if an NSG already exists.', validator=validate_nsg_name)
        c.argument('apply_to_subnet', help='Allow inbound traffic on the subnet instead of the NIC', action='store_true')
        c.argument('port', help="The port or port range (ex: 80-100) to open inbound traffic to. Use '*' to allow traffic to all ports.")
        c.argument('priority', help='Rule priority, between 100 (highest priority) and 4096 (lowest priority). Must be unique for each rule in the collection.', type=int)

    for scope in ['vm show', 'vm list']:
        with self.argument_context(scope) as c:
            c.argument('show_details', action='store_true', options_list=['--show-details', '-d'], help='show public ip address, FQDN, and power states. command will run slow')

    with self.argument_context('vm diagnostics') as c:
        c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'])

    with self.argument_context('vm diagnostics set') as c:
        c.argument('storage_account', completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'))

    with self.argument_context('vm disk') as c:
        c.argument('vm_name', options_list=['--vm-name'], id_part=None, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines'))
        c.argument('disk', validator=validate_vm_disk, help='disk name or ID', completer=get_resource_name_completion_list('Microsoft.Compute/disks'))
        c.argument('new', action='store_true', help='create a new disk')
        c.argument('sku', arg_type=disk_sku)
        c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB.')
        c.argument('lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virtual Machine size.')

    with self.argument_context('vm disk attach') as c:
        c.argument('enable_write_accelerator', min_api='2017-12-01', action='store_true', help='enable write accelerator')

    with self.argument_context('vm disk detach') as c:
        c.argument('disk_name', options_list=['--name', '-n'], help='The data disk name.')

    with self.argument_context('vm encryption enable') as c:
        c.argument('encrypt_format_all', action='store_true', help='Encrypts-formats data disks instead of encrypting them. Encrypt-formatting is a lot faster than in-place encryption but wipes out the partition getting encrypt-formatted.')

    with self.argument_context('vm extension') as c:
        c.argument('vm_extension_name', name_arg_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines/extensions'), help='extension name', id_part='child_name_1')
        c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'], id_part='name')

    with self.argument_context('vm extension list') as c:
        c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'], id_part=None)

    with self.argument_context('vm secret') as c:
        c.argument('secrets', multi_ids_type, options_list=['--secrets', '-s'], help='Space-separated list of key vault secret URIs. Perhaps, produced by \'az keyvault secret list-versions --vault-name vaultname -n cert1 --query "[?attributes.enabled].id" -o tsv\'')
        c.argument('keyvault', help='Name or ID of the key vault.', validator=validate_keyvault)
        c.argument('certificate', help='key vault certificate name or its full secret URL')
        c.argument('certificate_store', help='Windows certificate store names. Default: My')

    with self.argument_context('vm secret list') as c:
        c.argument('vm_name', arg_type=existing_vm_name, id_part=None)

    with self.argument_context('vm image') as c:
        c.argument('publisher_name', options_list=['--publisher', '-p'])
        c.argument('publisher', options_list=['--publisher', '-p'], help='image publisher')
        c.argument('offer', options_list=['--offer', '-f'], help='image offer')
        c.argument('plan', help='image billing plan')
        c.argument('sku', options_list=['--sku', '-s'], help='image sku')
        c.argument('version', help="image sku's version")
        c.argument('urn', help="URN, in format of 'publisher:offer:sku:versin'. If specified, other argument values can be omitted")

    with self.argument_context('vm image list') as c:
        c.argument('image_location', get_location_type(self.cli_ctx))

    with self.argument_context('vm image show') as c:
        c.argument('skus', options_list=['--sku', '-s'])

    with self.argument_context('vm nic') as c:
        c.argument('vm_name', existing_vm_name, options_list=['--vm-name'], id_part=None)
        c.argument('nics', nargs='+', help='Names or IDs of NICs.', validator=validate_vm_nics)
        c.argument('primary_nic', help='Name or ID of the primary NIC. If missing, the first NIC in the list will be the primary.')

    with self.argument_context('vm nic show') as c:
        c.argument('nic', help='NIC name or ID.', validator=validate_vm_nic)

    with self.argument_context('vm run-command') as c:
        c.argument('command_id', completer=get_vm_run_command_completion_list, help="The run command ID")

    with self.argument_context('vm run-command invoke') as c:
        c.argument('parameters', nargs='+', help="space-separated parameters in the format of '[name=]value'")
        c.argument('scripts', nargs='+', help="script lines separated by whites spaces. Use @{file} to load from a file")

    with self.argument_context('vm unmanaged-disk') as c:
        c.argument('vm_name', arg_type=existing_vm_name)
        c.argument('disk_size', help='Size of disk (GiB)', default=1023, type=int)
        c.argument('new', action='store_true', help='Create a new disk.')
        c.argument('lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virtual Machine size.')
        c.argument('vhd_uri', help="Virtual hard disk URI. For example: https://mystorage.blob.core.windows.net/vhds/d1.vhd")

    with self.argument_context('vm unmanaged-disk attach') as c:
        c.argument('disk_name', options_list=['--name', '-n'], help='The data disk name(optional when create a new disk)')

    with self.argument_context('vm unmanaged-disk detach') as c:
        c.argument('disk_name', options_list=['--name', '-n'], help='The data disk name.')

    for scope in ['vm unmanaged-disk attach', 'vm unmanaged-disk detach']:
        with self.argument_context(scope) as c:
            c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'], id_part=None)

    with self.argument_context('vm unmanaged-disk list') as c:
        c.argument('vm_name', arg_type=existing_vm_name, id_part=None)

    with self.argument_context('vm user') as c:
        c.argument('username', options_list=['--username', '-u'], help='The user name')
        c.argument('password', options_list=['--password', '-p'], help='The user password')
    # endregion

    # region VMSS
    scaleset_name_aliases = ['vm_scale_set_name', 'virtual_machine_scale_set_name', 'name']

    with self.argument_context('vmss') as c:
        c.argument('zones', zones_type, min_api='2017-03-30')
        c.argument('instance_id', id_part='child_name_1')
        c.argument('instance_ids', multi_ids_type, help='Space-separated list of IDs (ex: 1 2 3 ...) or * for all instances. If not provided, the action will be applied on the scaleset itself')
        c.argument('tags', tags_type)
        c.argument('caching', help='Disk caching policy', arg_type=get_enum_type(CachingTypes))
        for dest in scaleset_name_aliases:
            c.argument(dest, vmss_name_type)

    for scope in ['vmss deallocate', 'vmss delete-instances', 'vmss restart', 'vmss start', 'vmss stop', 'vmss show', 'vmss update-instances']:
        with self.argument_context(scope) as c:
            for dest in scaleset_name_aliases:
                c.argument(dest, vmss_name_type, id_part=None)  # due to instance-ids parameter

    with self.argument_context('vmss create') as c:
        VMPriorityTypes = self.get_models('VirtualMachinePriorityTypes', resource_type=ResourceType.MGMT_COMPUTE)
        VirtualMachineEvictionPolicyTypes = self.get_models('VirtualMachineEvictionPolicyTypes', resource_type=ResourceType.MGMT_COMPUTE)
        c.argument('name', name_arg_type)
        c.argument('nat_backend_port', default=None, help='Backend port to open with NAT rules.  Defaults to 22 on Linux and 3389 on Windows.')
        c.argument('single_placement_group', arg_type=get_three_state_flag(), help="Enable replicate using fault domains within the same cluster. Default to 'false' for any zonals, or with 100+ instances"
                   " See https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-placement-groups for details")
        c.argument('platform_fault_domain_count', type=int, help='Fault Domain count for each placement group in the availability zone', min_api='2017-12-01')
        c.argument('vmss_name', name_arg_type, id_part=None, help='Name of the virtual machine scale set.')
        c.argument('instance_count', help='Number of VMs in the scale set.', type=int)
        c.argument('disable_overprovision', help='Overprovision option (see https://azure.microsoft.com/en-us/documentation/articles/virtual-machine-scale-sets-overview/ for details).', action='store_true')
        c.argument('upgrade_policy_mode', help=None, arg_type=get_enum_type(UpgradeMode))
        c.argument('health_probe', help='(Preview) probe name from the existing load balancer, mainly used for rolling upgrade')
        c.argument('vm_sku', help='Size of VMs in the scale set.  See https://azure.microsoft.com/en-us/pricing/details/virtual-machines/ for size info.')
        c.argument('nsg', help='Name or ID of an existing Network Security Group.', arg_group='Network')
        c.argument('priority', resource_type=ResourceType.MGMT_COMPUTE, min_api='2017-12-01', arg_type=get_enum_type(VMPriorityTypes, default=None),
                   help="(PREVIEW)Priority. Use 'Low' to run short-lived workloads in a cost-effective way")
        c.argument('eviction_policy', resource_type=ResourceType.MGMT_COMPUTE, min_api='2017-12-01', arg_type=get_enum_type(VirtualMachineEvictionPolicyTypes, default=None),
                   help="(PREVIEW) the eviction policy for virtual machines in a low priority scale set.")

    with self.argument_context('vmss create', arg_group='Network Balancer') as c:
        LoadBalancerSkuName = self.get_models('LoadBalancerSkuName', resource_type=ResourceType.MGMT_NETWORK)
        c.argument('application_gateway', help='Name to use when creating a new application gateway (default) or referencing an existing one. Can also reference an existing application gateway by ID or specify "" for none.', options_list=['--app-gateway'])
        c.argument('app_gateway_capacity', help='The number of instances to use when creating a new application gateway.')
        c.argument('app_gateway_sku', help='SKU when creating a new application gateway.')
        c.argument('app_gateway_subnet_address_prefix', help='The subnet IP address prefix to use when creating a new application gateway in CIDR format.')
        c.argument('backend_pool_name', help='Name to use for the backend pool when creating a new load balancer or application gateway.')
        c.argument('backend_port', help='When creating a new load balancer, backend port to open with NAT rules (Defaults to 22 on Linux and 3389 on Windows). When creating an application gateway, the backend port to use for the backend HTTP settings.', type=int)
        c.argument('load_balancer', help='Name to use when creating a new load balancer (default) or referencing an existing one. Can also reference an existing load balancer by ID or specify "" for none.', options_list=['--load-balancer', '--lb'])
        c.argument('load_balancer_sku', resource_type=ResourceType.MGMT_NETWORK, min_api='2017-08-01', options_list=['--lb-sku'], arg_type=get_enum_type(LoadBalancerSkuName),
                   help="Sku of the Load Balancer to create. Default to 'Standard' when single placement group is turned off; otherwise, default to 'Basic'")
        c.argument('nat_pool_name', help='Name to use for the NAT pool when creating a new load balancer.', options_list=['--lb-nat-pool-name', '--nat-pool-name'])

    with self.argument_context('vmss create', min_api='2017-03-30', arg_group='Network') as c:
        c.argument('public_ip_per_vm', action='store_true', help="Each VM instance will have a public ip. For security, you can use '--nsg' to apply appropriate rules")
        c.argument('vm_domain_name', help="domain name of VM instances, once configured, the FQDN is 'vm<vm-index>.<vm-domain-name>.<..rest..>'")
        c.argument('dns_servers', nargs='+', help="space-separated IP addresses of DNS servers, e.g. 10.0.0.5 10.0.0.6")
        c.argument('accelerated_networking', action='store_true', help="enable accelerated networking")

    for scope in ['vmss update-instances', 'vmss delete-instances']:
        with self.argument_context(scope) as c:
            c.argument('instance_ids', multi_ids_type, help='Space-separated list of IDs (ex: 1 2 3 ...) or * for all instances.')

    with self.argument_context('vmss diagnostics') as c:
        c.argument('vmss_name', id_part=None, help='Scale set name')

    with self.argument_context('vmss disk') as c:
        c.argument('lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virtual Machine instance size.')
        c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB.')
        c.argument('vmss_name', vmss_name_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'))
        c.argument('disk', validator=validate_vmss_disk, help='existing disk name or ID to attach or detach from VM instances',
                   min_api='2017-12-01', completer=get_resource_name_completion_list('Microsoft.Compute/disks'))
        c.argument('instance_id', help='Scale set VM instance id', min_api='2017-12-01')

    with self.argument_context('vmss encryption') as c:
        c.argument('vmss_name', vmss_name_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'))

    with self.argument_context('vmss extension') as c:
        c.argument('extension_name', name_arg_type, help='Name of the extension.')
        c.argument('vmss_name', vmss_name_type, options_list=['--vmss-name'], id_part=None)

    with self.argument_context('vmss nic') as c:
        c.argument('virtual_machine_scale_set_name', options_list=['--vmss-name'], help='Scale set name.', completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'), id_part='name')
        c.argument('virtualmachine_index', options_list=['--instance-id'], id_part='child_name_1')
        c.argument('network_interface_name', options_list=['--name', '-n'], metavar='NIC_NAME', help='The network interface (NIC).', completer=get_resource_name_completion_list('Microsoft.Network/networkInterfaces'), id_part='child_name_2')

    with self.argument_context('vmss nic list') as c:
        c.argument('virtual_machine_scale_set_name', arg_type=vmss_name_type, options_list=['--vmss-name'], id_part=None)
    # endregion

    # region VM & VMSS Shared
    for scope in ['vm', 'vmss']:
        with self.argument_context(scope) as c:
            c.argument('no_auto_upgrade', action='store_true', help='by doing this, extension system will not pick the highest minor version for the specified version number, and will not auto update to the latest build/revision number on any scale set updates in future.')

    for scope in ['vm identity assign', 'vmss identity assign']:
        with self.argument_context(scope) as c:
            c.argument('assign_identity', options_list=['--identities'], nargs='*', help="the identities to assign")
            c.argument('vm_name', existing_vm_name)
            c.argument('vmss_name', vmss_name_type)

    for scope in ['vm identity remove', 'vmss identity remove']:
        with self.argument_context(scope) as c:
            c.argument('identities', nargs='+', help="space-separated user assigned identities to remove")
            c.argument('vm_name', existing_vm_name)
            c.argument('vmss_name', vmss_name_type)

    for scope in ['vm identity show', 'vmss identity show']:
        with self.argument_context(scope) as c:
            c.argument('vm_name', existing_vm_name)
            c.argument('vmss_name', vmss_name_type)

    for scope in ['vm create', 'vmss create']:
        with self.argument_context(scope) as c:
            c.argument('location', get_location_type(self.cli_ctx), help='Location in which to create VM and related resources. If default location is not configured, will default to the resource group\'s location')
            c.argument('tags', tags_type)
            c.argument('no_wait', help='Do not wait for the long-running operation to finish.')
            c.argument('validate', options_list=['--validate'], help='Generate and validate the ARM template without creating any resources.', action='store_true')
            c.argument('size', help='The VM size to be created. See https://azure.microsoft.com/en-us/pricing/details/virtual-machines/ for size info.')
            c.argument('image', completer=get_urn_aliases_completion_list)
            c.argument('custom_data', help='Custom init script file or text (cloud-init, cloud-config, etc..)', completer=FilesCompleter(), type=file_type)
            c.argument('secrets', multi_ids_type, help='One or many Key Vault secrets as JSON strings or files via `@<file path>` containing `[{ "sourceVault": { "id": "value" }, "vaultCertificates": [{ "certificateUrl": "value", "certificateStore": "cert store name (only on windows)"}] }]`', type=file_type, completer=FilesCompleter())
            c.argument('license_type', help="license type if the Windows image or disk used was licensed on-premises", arg_type=get_enum_type(['Windows_Server', 'Windows_Client']))
            c.argument('assign_identity', nargs='*', arg_group='Managed Service Identity', help="accept system or user assigned identities separated by spaces. Use '[system]' to refer system assigned identity, or a resource id to refer user assigned identity. Check out help for more examples")

        with self.argument_context(scope, arg_group='Authentication') as c:
            c.argument('generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing. The keys will be stored in the ~/.ssh directory')
            c.argument('admin_username', help='Username for the VM.')
            c.argument('admin_password', help="Password for the VM if authentication type is 'Password'.")
            c.argument('ssh_key_value', help='SSH public key or public key file path.', completer=FilesCompleter(), type=file_type)
            c.argument('ssh_dest_key_path', help='Destination file path on the VM for the SSH key.')
            c.argument('authentication_type', help='Type of authentication to use with the VM. Defaults to password for Windows and SSH public key for Linux.', arg_type=get_enum_type(['ssh', 'password']))

        with self.argument_context(scope, arg_group='Storage') as c:
            c.argument('os_disk_name', help='The name of the new VM OS disk.')
            c.argument('os_type', help='Type of OS installed on a custom VHD. Do not use when specifying an URN or URN alias.', arg_type=get_enum_type(['windows', 'linux']))
            c.argument('storage_account', help="Only applicable when used with `--use-unmanaged-disk`. The name to use when creating a new storage account or referencing an existing one. If omitted, an appropriate storage account in the same resource group and location will be used, or a new one will be created.")
            c.argument('storage_sku', help='The SKU of the storage account with which to persist VM. By default, only Standard_LRS and Premium_LRS are allowed. With `--use-unmanaged-disk`, all are available.', arg_type=get_enum_type(SkuName))
            c.argument('storage_container_name', help="Only applicable when used with `--use-unmanaged-disk`. Name of the storage container for the VM OS disk. Default: vhds")
            c.ignore('os_publisher', 'os_offer', 'os_sku', 'os_version', 'storage_profile')
            c.argument('use_unmanaged_disk', action='store_true', help='Do not use managed disk to persist VM')
            c.argument('data_disk_sizes_gb', nargs='+', type=int, help='space-separated empty managed data disk sizes in GB to create')
            c.ignore('disk_info', 'storage_account_type', 'public_ip_address_type', 'nsg_type', 'nic_type', 'vnet_type', 'load_balancer_type', 'app_gateway_type')
            c.argument('os_caching', options_list=['--storage-caching', '--os-disk-caching'], help='Storage caching type for the VM OS disk. Default: ReadWrite', arg_type=get_enum_type(CachingTypes))
            c.argument('data_caching', options_list=['--data-disk-caching'], nargs='+',
                       help="storage caching type for data disk(s), including 'None', 'ReadOnly', 'ReadWrite', etc. Use a singular value to apply on all disks, or use '<lun>=<vaule1> <lun>=<value2>' to configure individual disk")

        with self.argument_context(scope, arg_group='Network') as c:
            c.argument('vnet_name', help='Name of the virtual network when creating a new one or referencing an existing one.')
            c.argument('vnet_address_prefix', help='The IP address prefix to use when creating a new VNet in CIDR format.')
            c.argument('subnet', help='The name of the subnet when creating a new VNet or referencing an existing one. Can also reference an existing subnet by ID. If omitted, an appropriate VNet and subnet will be selected automatically, or a new one will be created.')
            c.argument('subnet_address_prefix', help='The subnet IP address prefix to use when creating a new VNet in CIDR format.')
            c.argument('nics', nargs='+', help='Names or IDs of existing NICs to attach to the VM. The first NIC will be designated as primary. If omitted, a new NIC will be created. If an existing NIC is specified, do not specify subnet, VNet, public IP or NSG.')
            c.argument('private_ip_address', help='Static private IP address (e.g. 10.0.0.5).')
            c.argument('public_ip_address', help='Name of the public IP address when creating one (default) or referencing an existing one. Can also reference an existing public IP by ID or specify "" for None.')
            c.argument('public_ip_address_allocation', help=None, default=None, arg_type=get_enum_type(['dynamic', 'static']))
            c.argument('public_ip_address_dns_name', help='Globally unique DNS name for a newly created public IP.')
            if self.supported_api_version(min_api='2017-08-01', resource_type=ResourceType.MGMT_NETWORK):
                PublicIPAddressSkuName = self.get_models('PublicIPAddressSkuName', resource_type=ResourceType.MGMT_NETWORK)
                c.argument('public_ip_sku', help='Sku', default=None, arg_type=get_enum_type(PublicIPAddressSkuName))

        with self.argument_context(scope, arg_group='Marketplace Image Plan') as c:
            c.argument('plan_name', help='plan name')
            c.argument('plan_product', help='plan product')
            c.argument('plan_publisher', help='plan publisher')
            c.argument('plan_promotion_code', help='plan promotion code')

    for scope in ['vm create', 'vmss create', 'vm identity assign', 'vmss identity assign']:
        with self.argument_context(scope) as c:
            arg_group = 'Managed Service Identity' if scope.split()[-1] == 'create' else None
            c.argument('identity_scope', options_list=['--scope'], arg_group=arg_group, help="Scope that the system assigned identity can access")
            c.argument('identity_role', options_list=['--role'], arg_group=arg_group, help="Role name or id the system assigned identity will have")
            c.ignore('identity_role_id')

    for scope in ['vm diagnostics', 'vmss diagnostics']:
        with self.argument_context(scope) as c:
            c.argument('version', help='version of the diagnostics extension. Will use the latest if not specfied')
            c.argument('settings', help='json string or a file path, which defines data to be collected.', type=validate_file_or_dict, completer=FilesCompleter())
            c.argument('protected_settings', help='json string or a file path containing private configurations such as storage account keys, etc.', type=validate_file_or_dict, completer=FilesCompleter())
            c.argument('is_windows_os', action='store_true', help='for Windows VMs')

    for scope in ['vm encryption', 'vmss encryption']:
        with self.argument_context(scope) as c:
            c.argument('volume_type', help='Type of volume that the encryption operation is performed on', arg_type=get_enum_type(['DATA', 'OS', 'ALL']))
            c.argument('force', action='store_true', help='continue by ignoring client side validation errors')
            c.argument('disk_encryption_keyvault', help='The key vault where the generated encryption key will be placed.')
            c.argument('key_encryption_key', help='Key vault key name or URL used to encrypt the disk encryption key.')
            c.argument('key_encryption_keyvault', help='The key vault containing the key encryption key used to encrypt the disk encryption key. If missing, CLI will use `--disk-encryption-keyvault`.')

    for scope in ['vm extension', 'vmss extension']:
        with self.argument_context(scope) as c:
            c.argument('publisher', help='The name of the extension publisher.')
            c.argument('settings', type=validate_file_or_dict, help='Extension settings in JSON format. A JSON file path is also accepted.')
            c.argument('protected_settings', type=validate_file_or_dict, help='Protected settings in JSON format for sensitive information like credentials. A JSON file path is also accepted.')
            c.argument('version', help='The version of the extension')

    for scope in ['vm extension image', 'vmss extension image']:
        with self.argument_context(scope) as c:
            c.argument('image_location', options_list=['--location', '-l'], help='Image location.')
            c.argument('name', help='Image name', id_part=None)
            c.argument('publisher_name', options_list=['--publisher', '-p'], help='Image publisher name')
            c.argument('type', options_list=['--name', '-n'], help='Name of the extension')
            c.argument('latest', action='store_true', help='Show the latest version only.')
            c.argument('version', help='Extension version')
            c.argument('orderby', help="the $orderby odata query option")
            c.argument('top', help='the $top odata query option')
示例#25
0
def load_arguments(self, _):  # pylint: disable=too-many-statements
    # Arguments for IoT DPS
    with self.argument_context('iot dps') as c:
        c.argument('dps_name', dps_name_type, options_list=['--name', '-n'], id_part='name')

    with self.argument_context('iot dps create') as c:
        c.argument('location', get_location_type(self.cli_ctx),
                   help='Location of your IoT Provisioning Service. Default is the location of target resource group.')
        c.argument('sku', arg_type=get_enum_type(IotDpsSku),
                   help='Pricing tier for the IoT provisioning service.')
        c.argument('unit', help='Units in your IoT Provisioning Service.', type=int)

    for subgroup in ['access-policy', 'linked-hub', 'certificate']:
        with self.argument_context('iot dps {}'.format(subgroup)) as c:
            c.argument('dps_name', options_list=['--dps-name'], id_part=None)

    with self.argument_context('iot dps access-policy') as c:
        c.argument('access_policy_name', options_list=['--access-policy-name', '--name', '-n'],
                   help='A friendly name for DPS access policy.')

    with self.argument_context('iot dps access-policy create') as c:
        c.argument('rights', options_list=['--rights', '-r'], nargs='+',
                   arg_type=get_enum_type(AccessRightsDescription),
                   help='Access rights for the IoT provisioning service. Use space-separated list for multiple rights.')
        c.argument('primary_key', help='Primary SAS key value.')
        c.argument('secondary_key', help='Secondary SAS key value.')

    with self.argument_context('iot dps access-policy update') as c:
        c.argument('rights', options_list=['--rights', '-r'], nargs='+',
                   arg_type=get_enum_type(AccessRightsDescription),
                   help='Access rights for the IoT provisioning service. Use space-separated list for multiple rights.')
        c.argument('primary_key', help='Primary SAS key value.')
        c.argument('secondary_key', help='Secondary SAS key value.')

    with self.argument_context('iot dps linked-hub') as c:
        c.argument('linked_hub', options_list=['--linked-hub'], help='Host name of linked IoT Hub.')

    with self.argument_context('iot dps linked-hub create') as c:
        c.argument('connection_string', help='Connection string of the IoT hub.')
        c.argument('location', get_location_type(self.cli_ctx),
                   help='Location of the IoT hub.')
        c.argument('apply_allocation_policy',
                   help='A boolean indicating whether to apply allocation policy to the IoT hub.',
                   arg_type=get_three_state_flag())
        c.argument('allocation_weight', help='Allocation weight of the IoT hub.')

    with self.argument_context('iot dps linked-hub update') as c:
        c.argument('apply_allocation_policy',
                   help='A boolean indicating whether to apply allocation policy to the Iot hub.',
                   arg_type=get_three_state_flag())
        c.argument('allocation_weight', help='Allocation weight of the IoT hub.')

    with self.argument_context('iot dps allocation-policy update') as c:
        c.argument('allocation_policy', options_list=['--policy', '-p'], arg_type=get_enum_type(AllocationPolicy),
                   help='Allocation policy for the IoT provisioning service.')

    with self.argument_context('iot dps certificate') as c:
        c.argument('certificate_path', options_list=['--path', '-p'], type=file_type,
                   completer=FilesCompleter([".cer", ".pem"]), help='The path to the file containing the certificate.')
        c.argument('certificate_name', options_list=['--certificate-name', '--name', '-n'],
                   help='A friendly name for the certificate.')
        c.argument('etag', options_list=['--etag', '-e'], help='Entity Tag (etag) of the object.')

    # Arguments for IoT Hub
    with self.argument_context('iot') as c:
        c.argument('device_id', options_list=['--device-id', '-d'], help='Device Id.',
                   completer=get_device_id_completion_list)

    with self.argument_context('iot hub') as c:
        c.argument('hub_name', hub_name_type, options_list=['--name', '-n'], id_part='name')
        c.argument('etag', options_list=['--etag', '-e'], help='Entity Tag (etag) of the object.')

    for subgroup in ['consumer-group', 'policy', 'job', 'certificate']:
        with self.argument_context('iot hub {}'.format(subgroup)) as c:
            c.argument('hub_name', options_list=['--hub-name'])

    with self.argument_context('iot device') as c:
        c.argument('hub_name', hub_name_type)

    with self.argument_context('iot hub certificate') as c:
        c.argument('certificate_path', options_list=['--path', '-p'], type=file_type,
                   completer=FilesCompleter([".cer", ".pem"]), help='The path to the file containing the certificate.')
        c.argument('certificate_name', options_list=['--name', '-n'], help='A friendly name for the certificate.')

    with self.argument_context('iot hub consumer-group') as c:
        c.argument('consumer_group_name', options_list=['--name', '-n'], id_part='child_name_2',
                   help='Event hub consumer group name.')
        c.argument('event_hub_name', id_part='child_name_1', help='Event hub endpoint name.')

    with self.argument_context('iot hub policy') as c:
        c.argument('policy_name', options_list=['--name', '-n'], id_part='child_name_1',
                   help='Shared access policy name.')
        permission_values = ', '.join([x.value for x in SimpleAccessRights])
        c.argument('permissions', nargs='*', validator=validate_policy_permissions, type=str.lower,
                   help='Permissions of shared access policy. Use space-separated list for multiple permissions. '
                        'Possible values: {}'.format(permission_values))

    with self.argument_context('iot hub job') as c:
        c.argument('job_id', id_part='child_name_1', help='Job Id.')

    with self.argument_context('iot hub create') as c:
        c.argument('hub_name', completer=None)
        c.argument('location', get_location_type(self.cli_ctx),
                   help='Location of your IoT Hub. Default is the location of target resource group.')
        c.argument('sku', arg_type=get_enum_type(IotHubSku),
                   help='Pricing tier for Azure IoT Hub. Default value is F1, which is free. '
                        'Note that only one free IoT hub instance is allowed in each '
                        'subscription. Exception will be thrown if free instances exceed one.')
        c.argument('unit', help='Units in your IoT Hub.', type=int)
        c.argument('partition_count', help='The number of partitions for device-to-cloud messages.', type=int)

    with self.argument_context('iot hub show-connection-string') as c:
        c.argument('policy_name', help='Shared access policy to use.')
        c.argument('key_type', arg_type=get_enum_type(KeyType), options_list=['--key'], help='The key to use.')

    with self.argument_context('iot device create') as c:
        c.argument('device_id', completer=None)

    with self.argument_context('iot device create', arg_group='X.509 Certificate') as c:
        c.argument('x509', action='store_true', help='Use X.509 certificate for device authentication.')
        c.argument('primary_thumbprint', help='Primary X.509 certificate thumbprint to authenticate device.')
        c.argument('secondary_thumbprint', help='Secondary X.509 certificate thumbprint to authenticate device.')
        c.argument('valid_days', type=int, help='Number of days the generated self-signed X.509 certificate should be '
                                                'valid for. Default validity is 365 days.')
        c.argument('output_dir', help='Output directory for generated self-signed X.509 certificate. '
                                      'Default is current working directory.')

    with self.argument_context('iot device list') as c:
        c.argument('top', help='Maximum number of device identities to return.', type=int)

    with self.argument_context('iot device delete') as c:
        c.argument('etag', help='ETag of the target device. It is used for the purpose of optimistic '
                                'concurrency. Delete operation will be performed only if the specified '
                                'ETag matches the value maintained by the server, indicating that the '
                                'device identity has not been modified since it was retrieved. Default '
                                'value is set to wildcard character (*) to force an unconditional '
                                'delete.')

    with self.argument_context('iot device show-connection-string') as c:
        c.argument('top', type=int, help='Maximum number of connection strings to return.')
        c.argument('key_type', arg_type=get_enum_type(KeyType), options_list=['--key'], help='The key to use.')

    with self.argument_context('iot device message') as c:
        c.argument('lock_token', help='Message lock token.')

    with self.argument_context('iot device message send', arg_group='Messaging') as c:
        c.argument('data', help='Device-to-cloud message body.')
        c.argument('message_id', help='Device-to-cloud message Id.')
        c.argument('correlation_id', help='Device-to-cloud message correlation Id.')
        c.argument('user_id', help='Device-to-cloud message user Id.')

    with self.argument_context('iot device message receive') as c:
        c.argument('lock_timeout', type=int,
                   help='In case a message returned to this call, this specifies the amount of '
                        'time in seconds, the message will be invisible to other receive calls.')

    with self.argument_context('iot device export') as c:
        c.argument('blob_container_uri',
                   help='Blob Shared Access Signature URI with write access to a blob container.'
                        'This is used to output the status of the job and the results.')
        c.argument('include_keys', action='store_true',
                   help='If set, keys are exported normally. Otherwise, keys are set to null in '
                        'export output.')

    with self.argument_context('iot device import') as c:
        c.argument('input_blob_container_uri',
                   help='Blob Shared Access Signature URI with read access to a blob container.'
                        'This blob contains the operations to be performed on the identity '
                        'registry ')
        c.argument('output_blob_container_uri',
                   help='Blob Shared Access Signature URI with write access to a blob container.'
                        'This is used to output the status of the job and the results.')
示例#26
0
def load_arguments_eh(self, _):
    from knack.arguments import CLIArgumentType
    from azure.mgmt.eventhub.models import KeyType, AccessRights, SkuName
    from azure.cli.command_modules.eventhubs._completers import get_consumergroup_command_completion_list, get_eventhubs_command_completion_list
    from azure.cli.command_modules.eventhubs._validator import validate_storageaccount, validate_partner_namespace

    rights_arg_type = CLIArgumentType(options_list=['--rights'], nargs='+', arg_type=get_enum_type(AccessRights), help='Space-separated list of Authorization rule rights')
    key_arg_type = CLIArgumentType(options_list=['--key'], arg_type=get_enum_type(KeyType), help='specifies Primary or Secondary key needs to be reset')
    keyvalue_arg_type = CLIArgumentType(options_list=['--key-value'], help='Optional, if the key value provided, is set for KeyType or autogenerated Key value set for keyType.')
    event_hub_name_arg_type = CLIArgumentType(options_list=['--eventhub-name'], help='Name of EventHub')
    namespace_name_arg_type = CLIArgumentType(options_list=['--namespace-name'], help='Name of Namespace', id_part='name')

    with self.argument_context('eventhubs') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('namespace_name', id_part='name', help='name of Namespace')

    with self.argument_context('eventhubs namespace exists') as c:
        c.argument('namespace_name', arg_type=name_type, help='Namespace name. Name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number.')

    with self.argument_context('eventhubs namespace') as c:
        c.argument('namespace_name', arg_type=name_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.ServiceBus/namespaces'), help='Name of Namespace')
        c.argument('is_kafka_enabled', options_list=['--enable-kafka'], arg_type=get_three_state_flag(),
                   help='A boolean value that indicates whether Kafka is enabled for eventhub namespace.')

    with self.argument_context('eventhubs namespace create') as c:
        c.argument('tags', arg_type=tags_type)
        c.argument('sku', options_list=['--sku'], arg_type=get_enum_type(SkuName))
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('capacity', type=int, help='Capacity for Sku')
        c.argument('is_auto_inflate_enabled', options_list=['--enable-auto-inflate'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether AutoInflate is enabled for eventhub namespace.')
        c.argument('maximum_throughput_units', type=int, help='Upper limit of throughput units when AutoInflate is enabled, vaule should be within 0 to 20 throughput units. ( 0 if AutoInflateEnabled = true)')

    with self.argument_context('eventhubs namespace update') as c:
        c.argument('tags', arg_type=tags_type)
        c.argument('sku', options_list=['--sku'], arg_type=get_enum_type(SkuName))
        c.argument('capacity', type=int, help='Capacity for Sku')
        c.argument('is_auto_inflate_enabled', options_list=['--enable-auto-inflate'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether AutoInflate is enabled for eventhub namespace.')
        c.argument('maximum_throughput_units', type=int, help='Upper limit of throughput units when AutoInflate is enabled, vaule should be within 0 to 20 throughput units. ( 0 if AutoInflateEnabled = true)')

    # region Namespace Authorizationrule
    with self.argument_context('eventhubs namespace authorization-rule list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs namespace authorization-rule keys list') as c:
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='Name of Namespace AuthorizationRule')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    for scope in ['eventhubs namespace authorization-rule', 'eventhubs namespace authorization-rule keys renew']:
        with self.argument_context(scope) as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_1', help='Name of Namespace AuthorizationRule')
            c.argument('namespace_name', arg_type=namespace_name_arg_type)

    for scope in ['eventhubs namespace authorization-rule create', 'eventhubs namespace authorization-rule update', 'eventhubs eventhub authorization-rule create', 'eventhubs eventhub authorization-rule update']:
        with self.argument_context(scope) as c:
            c.argument('rights', arg_type=rights_arg_type)

    with self.argument_context('eventhubs namespace authorization-rule keys renew') as c:
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)


# region - Eventhub Create
    with self.argument_context('eventhubs eventhub') as c:
        c.argument('event_hub_name', arg_type=name_type, id_part='child_name_1', completer=get_eventhubs_command_completion_list, help='Name of Eventhub')

    for scope in ['eventhubs eventhub update', 'eventhubs eventhub create']:
        with self.argument_context(scope) as c:
            c.argument('message_retention_in_days', options_list=['--message-retention'], type=int, help='Number of days to retain events for this Event Hub, value should be 1 to 7 days')
            c.argument('partition_count', type=int, help='Number of partitions created for the Event Hub. By default, allowed values are 2-32. Lower value of 1 is supported with Kafka enabled namespaces. In presence of a custom quota, the upper limit will match the upper limit of the quota.')
            c.argument('status', arg_type=get_enum_type(['Active', 'Disabled', 'SendDisabled', 'ReceiveDisabled']), help='Status of Eventhub')
            c.argument('enabled', options_list=['--enable-capture'], arg_type=get_three_state_flag(), help='A boolean value that indicates whether capture description is enabled.')
            c.argument('capture_interval_seconds', arg_group='Capture', options_list=['--capture-interval'], type=int, help='Allows you to set the frequency with which the capture to Azure Blobs will happen, value should between 60 to 900 seconds')
            c.argument('capture_size_limit_bytes', arg_group='Capture', options_list=['--capture-size-limit'], type=int, help='Defines the amount of data built up in your Event Hub before an capture operation, value should be between 10485760 to 524288000 bytes')
            c.argument('destination_name', arg_group='Capture-Destination', help='Name for capture destination')
            c.argument('storage_account_resource_id', arg_group='Capture-Destination', validator=validate_storageaccount, options_list=['--storage-account'], help='Name (if within same resource group and not of type Classic Storage) or ARM id of the storage account to be used to create the blobs')
            c.argument('blob_container', arg_group='Capture-Destination', help='Blob container Name')
            c.argument('archive_name_format', arg_group='Capture-Destination', help='Blob naming convention for archive, e.g. {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order')

    with self.argument_context('eventhubs eventhub list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    # region EventHub Authorizationrule
    for scope in ['eventhubs eventhub authorization-rule', 'eventhubs eventhub authorization-rule keys renew']:
        with self.argument_context(scope) as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='Name of EventHub AuthorizationRule')
            c.argument('event_hub_name', id_part='child_name_1', arg_type=event_hub_name_arg_type)

    for scope in ['eventhubs eventhub authorization-rule create', 'eventhubs eventhub authorization-rule update']:
        with self.argument_context(scope) as c:
            c.argument('rights', arg_type=rights_arg_type)

    with self.argument_context('eventhubs eventhub authorization-rule keys renew') as c:
        c.argument('key_type', arg_type=key_arg_type)
        c.argument('key', arg_type=keyvalue_arg_type)

    with self.argument_context('eventhubs eventhub authorization-rule list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('event_hub_name', id_part=None, arg_type=event_hub_name_arg_type)

    with self.argument_context('eventhubs eventhub authorization-rule keys list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('event_hub_name', id_part=None, arg_type=event_hub_name_arg_type)
        c.argument('authorization_rule_name', arg_type=name_type, id_part=None, help='Name of EventHub AuthorizationRule')


# - ConsumerGroup Region
    with self.argument_context('eventhubs eventhub consumer-group') as c:
        c.argument('event_hub_name', arg_type=event_hub_name_arg_type)
        c.argument('consumer_group_name', arg_type=name_type, id_part='child_name_2', completer=get_consumergroup_command_completion_list, help='Name of ConsumerGroup')

    for scope in ['eventhubs eventhub consumer-group create', 'eventhubs eventhub consumer-group update']:
        with self.argument_context(scope) as c:
            c.argument('user_metadata', help='Usermetadata is a placeholder to store user-defined string data with maximum length 1024. e.g. it can be used to store descriptive data, such as list of teams and their contact information also user-defined configuration settings can be stored.')

    with self.argument_context('eventhubs eventhub consumer-group list') as c:
        c.argument('event_hub_name', arg_type=event_hub_name_arg_type, id_part=None)
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

#   : Region Geo DR Configuration
    with self.argument_context('eventhubs georecovery-alias') as c:
        c.argument('alias', options_list=['--alias', '-a'], id_part='child_name_1', help='Name of Geo-Disaster Recovery Configuration Alias')

    with self.argument_context('eventhubs georecovery-alias exists') as c:
        c.argument('name', options_list=['--alias', '-a'], arg_type=name_type, help='Name of Geo Recovery Configs - Alias to check availability')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs georecovery-alias set') as c:
        c.argument('partner_namespace', required=True, validator=validate_partner_namespace, help='Name (if within the same resource group) or ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing')
        c.argument('alternate_name', help='Alternate Name for the Alias, when the Namespace name and Alias name are same')

    for scope in ['eventhubs georecovery-alias authorization-rule show']:
        with self.argument_context(scope)as c:
            c.argument('authorization_rule_name', arg_type=name_type, id_part='child_name_2', help='Name of Namespace AuthorizationRule')

    with self.argument_context('eventhubs georecovery-alias list') as c:
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs georecovery-alias authorization-rule list') as c:
        c.argument('alias', options_list=['--alias', '-a'], help='Name of Geo-Disaster Recovery Configuration Alias')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')

    with self.argument_context('eventhubs georecovery-alias authorization-rule keys list') as c:
        c.argument('alias', options_list=['--alias', '-a'], id_part=None, help='Name of Geo-Disaster Recovery Configuration Alias')
        c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of Namespace')
        c.argument('authorization_rule_name', arg_type=name_type, help='Name of Namespace AuthorizationRule')
示例#27
0
def load_arguments(self, _):
    with self.argument_context('ad') as c:
        c.ignore('_subscription')  # hide global subscription param
        c.argument('owner_object_id', help="owner's object id")
        c.argument('show_mine', action='store_true', help='list entities owned by the current user')
        c.argument('include_all', options_list='--all', action='store_true',
                   help='list all entities, expect long delay if under a big organization')

    with self.argument_context('ad app') as c:
        c.argument('app_id', help='application id')
        c.argument('application_object_id', options_list=('--object-id',))
        c.argument('display_name', help='the display name of the application')
        c.argument('homepage', help='the url where users can sign in and use your app.')
        c.argument('identifier', options_list=['--id'], help='identifier uri, application id, or object id')
        c.argument('identifier_uris', nargs='+', help='space-separated unique URIs that Azure AD can use for this app.')
        c.argument('reply_urls', nargs='+', help='space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request. The value does not need to be a physical endpoint, but must be a valid URI.')
        c.argument('start_date', help="Date or datetime at which credentials become valid(e.g. '2017-01-01T01:00:00+00:00' or '2017-01-01'). Default value is current time")
        c.argument('end_date', help="Date or datetime after which credentials expire(e.g. '2017-12-31T11:59:59+00:00' or '2017-12-31'). Default value is one year after current time")
        c.argument('available_to_other_tenants', help='the application can be used from any Azure AD tenants', arg_type=get_three_state_flag())
        c.argument('key_value', help='the value for the key credentials associated with the application')
        # TODO: Update these with **enum_choice_list(...) when SDK supports proper enums
        c.argument('key_type', help='the type of the key credentials associated with the application', arg_type=get_enum_type(['AsymmetricX509Cert', 'Password', 'Symmetric'], default='AsymmetricX509Cert'))
        c.argument('key_usage', help='the usage of the key credentials associated with the application.', arg_type=get_enum_type(['Sign', 'Verify'], default='Verify'))
        c.argument('password', help="app password, aka 'client secret'")
        c.argument('oauth2_allow_implicit_flow', arg_type=get_three_state_flag(), help='whether to allow implicit grant flow for OAuth2')
        c.argument('required_resource_accesses', type=validate_file_or_dict,
                   help="resource scopes and roles the application requires access to. Should be in manifest json format. See examples below for details")
        c.argument('app_roles', type=validate_file_or_dict,
                   help="declare the roles you want to associate with your application. Should be in manifest json format. See examples below for details")
        c.argument('optional_claims', type=validate_file_or_dict,
                   help="declare the optional claims for the application. Should be in manifest json format. See examples below for details. Please reference https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-optional-claims#optionalclaim-type for optional claim properties.")
        c.argument('native_app', arg_type=get_three_state_flag(), help="an application which can be installed on a user's device or computer")
        c.argument('credential_description', help="the description of the password")

    with self.argument_context('ad app owner list') as c:
        c.argument('identifier', options_list=['--id'], help='identifier uri, application id, or object id of the application')

    with self.argument_context('ad app permission') as c:
        # https://github.com/Azure/azure-rest-api-specs/blob/32e56f061668a1bf1eeca6209000fad4c09afca8/specification/graphrbac/data-plane/Microsoft.GraphRbac/stable/1.6/graphrbac.json#L2817
        c.argument('api', help='Specify `RequiredResourceAccess.resourceAppId` - The unique identifier for the resource that the application requires access to. This should be equal to the appId declared on the target resource application.')
        # https://github.com/Azure/azure-rest-api-specs/blob/32e56f061668a1bf1eeca6209000fad4c09afca8/specification/graphrbac/data-plane/Microsoft.GraphRbac/stable/1.6/graphrbac.json#L2833
        c.argument('api_permissions', nargs='+', help='Specify `ResourceAccess.id` - The unique identifier for one of the OAuth2Permission or AppRole instances that the resource application exposes. Space-separated list of `<resource-access-id>=<type>`.')
        c.argument('expires', help='Expiry date for the permissions in years. e.g. 1, 2 or "never"')
        c.argument('scope', help='Specifies the value of the scope claim that the resource application should expect in the OAuth 2.0 access token, e.g. User.Read')
        c.argument('consent_type', arg_type=get_enum_type(ConsentType), default=ConsentType.all_principals.value,
                   help="Indicates if consent was provided by the administrator (on behalf of the organization) or by an individual.")
        c.argument('principal_id', help='If --consent-type is "Principal", this argument specifies the object of the user that granted consent and applies only for that user.')
        c.argument('show_resource_name', options_list=['--show-resource-name', '-r'],
                   arg_type=get_three_state_flag(), help="show resource's display name")

    with self.argument_context('ad app permission delete') as c:
        # `=<type>` is not needed.
        c.argument('api_permissions', nargs='+', help='Specify `ResourceAccess.id` - The unique identifier for one of the OAuth2Permission or AppRole instances that the resource application exposes. Space-separated list of `<resource-access-id>`.')

    with self.argument_context('ad app permission list') as c:
        c.argument('identifier', options_list=['--id'], help='identifier uri, application id, or object id of the associated application')

    with self.argument_context('ad sp') as c:
        c.argument('identifier', options_list=['--id'], help='service principal name, or object id')

    with self.argument_context('ad sp create') as c:
        c.argument('identifier', options_list=['--id'], help='identifier uri, application id, or object id of the associated application')

    with self.argument_context('ad sp create-for-rbac') as c:
        c.argument('scopes', nargs='+')
        c.argument('role', completer=get_role_definition_name_completion_list)
        c.argument('skip_assignment', arg_type=get_three_state_flag(),
                   help='Skip creating the default assignment, which allows the service principal to access resources under the current subscription. '
                        'When specified, --scopes will be ignored. You may use `az role assignment create` to create '
                        'role assignments for this service principal later.')
        c.argument('show_auth_for_sdk', options_list='--sdk-auth', help='output result in compatible with Azure SDK auth file', arg_type=get_three_state_flag())

    with self.argument_context('ad sp owner list') as c:
        c.argument('identifier', options_list=['--id'], help='service principal name, or object id or the service principal')

    for item in ['create-for-rbac', 'credential reset']:
        with self.argument_context('ad sp {}'.format(item)) as c:
            c.argument('name', name_arg_type)
            c.argument('cert', arg_group='Credential', validator=validate_cert)
            c.argument('years', type=int, default=None, arg_group='Credential')
            c.argument('end_date', default=None, arg_group='Credential',
                       help="Finer grain of expiry time if '--years' is insufficient, e.g. '2020-12-31T11:59:59+00:00' or '2299-12-31'")
            c.argument('create_cert', action='store_true', arg_group='Credential')
            c.argument('keyvault', arg_group='Credential')
            c.argument('append', action='store_true', help='Append the new credential instead of overwriting.')
            c.argument('credential_description', help="the description of the password", arg_group='Credential')

    with self.argument_context('ad sp credential reset') as c:
        c.argument('password', options_list=['--password', '-p'], arg_group='Credential',
                   help="If missing, CLI will generate a strong password")

    with self.argument_context('ad app credential reset') as c:
        c.argument('name', options_list=['--id'], help='identifier uri, application id, or object id')
        c.argument('cert', arg_group='Credential', validator=validate_cert, help='Certificate to use for credentials')
        c.argument('password', options_list=['--password', '-p'], arg_group='Credential')
        c.argument('years', type=int, default=None, arg_group='Credential', help='Number of years for which the credentials will be valid')
        c.argument('create_cert', action='store_true', arg_group='Credential', help='Create a self-signed certificate to use for the credential')
        c.argument('keyvault', arg_group='Credential', help='Name or ID of a KeyVault to use for creating or retrieving certificates.')
        c.argument('append', action='store_true', help='Append the new credential instead of overwriting.')

    for item in ['ad sp credential delete', 'ad sp credential list', 'ad app credential delete', 'ad app credential list']:
        with self.argument_context(item) as c:
            c.argument('key_id', help='credential key id')
            c.argument('cert', action='store_true', help='a certificate based credential')

    with self.argument_context('ad') as c:
        c.argument('display_name', help='object\'s display name or its prefix')
        c.argument('identifier_uri', help='graph application identifier, must be in uri format')
        c.argument('spn', help='service principal name')
        c.argument('upn', help='user principal name, e.g. [email protected]')
        c.argument('query_filter', options_list=['--filter'], help='OData filter, e.g. --filter "displayname eq \'test\' and servicePrincipalType eq \'Application\'"')

    with self.argument_context('ad user') as c:
        c.argument('mail_nickname', help='mail alias. Defaults to user principal name')
        c.argument('force_change_password_next_login', arg_type=get_three_state_flag(), help='Require the user to change their password the next time they log in. Only valid when --password is specified')
        c.argument('account_enabled', arg_type=get_three_state_flag(), help='enable the user account')
        c.argument('password', help='user password')
        c.argument('upn_or_object_id', options_list=['--id', c.deprecate(target='--upn-or-object-id', redirect='--id', hide=True)], help='The object ID or principal name of the user for which to get information')

    with self.argument_context('ad user get-member-groups') as c:
        c.argument('security_enabled_only', action='store_true',
                   help='If true, only membership in security-enabled groups should be checked. Otherwise, membership in all groups should be checked.')

    group_help_msg = "group's object id or display name(prefix also works if there is a unique match)"
    with self.argument_context('ad group') as c:
        for arg in VARIANT_GROUP_ID_ARGS:
            c.argument(arg, options_list=['--group', '-g'], validator=validate_group, help=group_help_msg)

    with self.argument_context('ad group create') as c:
        c.argument('mail_nickname', help='Mail nickname')
        c.argument('force', arg_type=get_three_state_flag(),
                   help='always create a new group instead of updating the one with same display and mail nickname')
        c.argument('description', help='Group description')

    with self.argument_context('ad group show') as c:
        c.extra('cmd')

    member_id_help_msg = 'The object ID of the contact, group, user, or service principal'
    with self.argument_context('ad group get-member-groups') as c:
        c.argument('security_enabled_only', arg_type=get_three_state_flag(), default=False, required=False)
        c.extra('cmd')

    with self.argument_context('ad group member add') as c:
        c.argument('url', options_list='--member-id', validator=validate_member_id, help=member_id_help_msg)

    for item in ['member add', 'member check', 'member list', 'member remove', 'delete']:
        with self.argument_context('ad group {}'.format(item)) as c:
            c.extra('cmd')

    with self.argument_context('ad group member') as c:
        c.argument('member_object_id', options_list='--member-id', help=member_id_help_msg)

    with self.argument_context('ad signed-in-user') as c:
        c.argument('object_type', options_list=['--type', '-t'], help='object type filter, e.g. "application", "servicePrincipal"  "group", etc')

    with self.argument_context('role') as c:
        c.argument('scope', help='scope at which the role assignment or definition applies to, e.g., /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333, /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup, or /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM')
        c.argument('resource_group_name', options_list=['--resource-group', '-g'], help='use it only if the role or assignment was added at the level of a resource group')

    with self.argument_context('role assignment') as c:
        c.argument('role_assignment_name', options_list=['--name', '-n'])
        c.argument('role', help='role name or id', completer=get_role_definition_name_completion_list)
        c.argument('show_all', options_list=['--all'], action='store_true', help='show all assignments under the current subscription')
        c.argument('include_inherited', action='store_true', help='include assignments applied on parent scopes')
        c.argument('can_delegate', action='store_true', help='when set, the assignee will be able to create further role assignments to the same role')
        c.argument('assignee', help='represent a user, group, or service principal. supported format: object id, user sign-in name, or service principal name')
        c.argument('assignee_object_id', help="Use this parameter instead of '--assignee' to bypass Graph API invocation in case of insufficient privileges. "
                   "This parameter only works with object ids for users, groups, service principals, and "
                   "managed identities. For managed identities use the principal id. For service principals, "
                   "use the object id and not the app id.")
        c.argument('ids', nargs='+', help='space-separated role assignment ids')
        c.argument('include_classic_administrators', arg_type=get_three_state_flag(), help='list default role assignments for subscription classic administrators, aka co-admins')
        c.argument('description', is_preview=True, min_api='2020-04-01-preview', help='Description of role assignment.')
        c.argument('condition', is_preview=True, min_api='2020-04-01-preview', help='Condition under which the user can be granted permission.')
        c.argument('condition_version', is_preview=True, min_api='2020-04-01-preview', help='Version of the condition syntax. If --condition is specified without --condition-version, default to 2.0.')

    time_help = ('The {} of the query in the format of %Y-%m-%dT%H:%M:%SZ, e.g. 2000-12-31T12:59:59Z. Defaults to {}')
    with self.argument_context('role assignment list-changelogs') as c:
        c.argument('start_time', help=time_help.format('start time', '1 Hour prior to the current time'))
        c.argument('end_time', help=time_help.format('end time', 'the current time'))

    with self.argument_context('role assignment create') as c:
        # PrincipalType = self.get_models('PrincipalType', resource_type=ResourceType.MGMT_AUTHORIZATION)

        # A temporary fix for https://github.com/Azure/azure-cli/issues/11594
        # As only 'User', 'Group' or 'ServicePrincipal' are allowed values, the REST spec contains invalid values
        # (like MSI) which are used only internally by the service. So hide them.
        # https://github.com/Azure/azure-rest-api-specs/blob/962013a1cf9bf5b87e3aad75a14c7dd620acda62/specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-04-01-preview/authorization-RoleAssignmentsCalls.json#L508-L522
        from enum import Enum

        class PrincipalType(str, Enum):
            user = "******"
            group = "Group"
            service_principal = "ServicePrincipal"

        c.argument('assignee_principal_type', min_api='2018-09-01-preview', arg_type=get_enum_type(PrincipalType),
                   help='use with --assignee-object-id to avoid errors caused by propagation latency in AAD Graph')

    with self.argument_context('role assignment update') as c:
        c.argument('role_assignment',
                   help='Description of an existing role assignment as JSON, or a path to a file containing a '
                        'JSON description.')

    with self.argument_context('role assignment delete') as c:
        c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Continue to delete all assignments under the subscription')

    with self.argument_context('role definition') as c:
        c.argument('role_definition_id', options_list=['--name', '-n'], help='the role definition name')
        c.argument('custom_role_only', arg_type=get_three_state_flag(), help='custom roles only(vs. build-in ones)')
        c.argument('role_definition', help="json formatted content which defines the new role.")
        c.argument('name', arg_type=name_arg_type, completer=get_role_definition_name_completion_list, help="the role's name")

    with self.argument_context('identity') as c:
        c.argument('resource_name', arg_type=name_arg_type, id_part='name')

    with self.argument_context('identity create') as c:
        c.argument('location', get_location_type(self.cli_ctx))
        c.argument('tags', tags_type)
示例#28
0
def load_arguments(self, _):  # pylint: disable=too-many-locals, too-many-statements
    from argcomplete.completers import FilesCompleter
    from six import u as unicode_string

    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

    t_base_blob_service = self.get_sdk('blob.baseblobservice#BaseBlobService')
    t_file_service = self.get_sdk('file#FileService')
    t_queue_service = self.get_sdk('queue#QueueService')
    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'))
    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'))
    file_name_type = CLIArgumentType(options_list=['--file-name', '-f'],
                                     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'))
    queue_name_type = CLIArgumentType(options_list=['--queue-name', '-q'], help='The queue name.',
                                      completer=get_storage_name_completion_list(t_queue_service, 'list_queues'))
    progress_type = CLIArgumentType(help='Include this flag to disable progress reporting for the command.',
                                    action='store_true', validator=add_progress_callback)
    socket_timeout_type = CLIArgumentType(help='The socket timeout(secs), used by the service to regulate data flow.',
                                          type=int)

    sas_help = 'The permissions the SAS grants. Allowed values: {}. Do not use if a stored access policy is ' \
               'referenced with --id that specifies this value. Can be combined.'

    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', 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')

    for item in ['delete', 'list', 'show', 'show-usage', 'update', 'keys']:
        with self.argument_context('storage account {}'.format(item)) as c:
            c.argument('account_name', acct_name_type, options_list=['--name', '-n'])

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

    with self.argument_context('storage account create') as c:
        t_account_type, t_sku_name, t_kind = self.get_models('AccountType', 'SkuName', 'Kind',
                                                             resource_type=ResourceType.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)
        c.argument('kind', help='Indicates the type of storage account.',
                   arg_type=get_enum_type(t_kind, default='storage'))
        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'))

    with self.argument_context('storage account update') as c:
        c.register_common_storage_account_options()
        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)

    with self.argument_context('storage account update', arg_group='Customer managed key', min_api='2017-06-01') as c:
        c.extra('encryption_key_name', help='The name of the KeyVault key', )
        c.extra('encryption_key_vault', help='The Uri of the KeyVault')
        c.extra('encryption_key_version', help='The version of the KeyVault key')
        c.argument('encryption_key_source',
                   arg_type=get_enum_type(['Microsoft.Storage', 'Microsoft.Keyvault'], 'Microsoft.Storage'),
                   help='The default encryption service',
                   validator=validate_encryption_source)
        c.ignore('encryption_key_vault_properties')

    for scope in ['storage account create', 'storage account update']:
        with self.argument_context(scope, resource_type=ResourceType.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=ResourceType.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.')

    with self.argument_context('storage account show-connection-string') as c:
        c.argument('account_name', acct_name_type, options_list=['--name', '-n'])
        c.argument('protocol', help='The default endpoint protocol.', arg_type=get_enum_type(['http', 'https']))
        c.argument('key_name', options_list=['--key'], help='The key to use.',
                   arg_type=get_enum_type(list(storage_account_key_options.keys())))
        for item in ['blob', 'file', 'queue', 'table']:
            c.argument('{}_endpoint'.format(item), help='Custom endpoint for {}s.'.format(item))

    with self.argument_context('storage account keys renew') as c:
        c.argument('key_name', options_list=['--key'], help='The key to regenerate.', validator=validate_key,
                   arg_type=get_enum_type(list(storage_account_key_options.keys())))
        c.argument('account_name', acct_name_type, id_part=None)

    with self.argument_context('storage account keys list') as c:
        c.argument('account_name', acct_name_type, id_part=None)

    with self.argument_context('storage account network-rule') as c:
        from ._validators import validate_subnet
        c.argument('storage_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.')

    with self.argument_context('storage account generate-sas') as c:
        t_account_permissions = self.get_sdk('common.models#AccountPermissions')
        c.register_sas_arguments()
        c.argument('services', type=services_type(self))
        c.argument('resource_types', type=resource_type_type(self))
        c.argument('expiry', type=get_datetime_type(True))
        c.argument('start', type=get_datetime_type(True))
        c.argument('account_name', acct_name_type, options_list=('--account-name',))
        c.argument('permission', options_list=('--permissions',),
                   help='The permissions the SAS grants. Allowed values: {}. Can be combined.'.format(
                       get_permission_help_string(t_account_permissions)),
                   validator=get_permission_validator(t_account_permissions))
        c.ignore('sas_token')

    with self.argument_context('storage logging show') as c:
        c.extra('services', validator=get_char_options_validator('bqt', 'services'), default='bqt')

    with self.argument_context('storage logging update') as c:
        c.extra('services', validator=get_char_options_validator('bqt', 'services'), options_list='--services',
                required=True)
        c.argument('log', validator=get_char_options_validator('rwd', 'log'))
        c.argument('retention', type=int)

    with self.argument_context('storage metrics show') as c:
        c.extra('services', validator=get_char_options_validator('bfqt', 'services'), default='bfqt')
        c.argument('interval', arg_type=get_enum_type(['hour', 'minute', 'both']))

    with self.argument_context('storage metrics update') as c:
        c.extra('services', validator=get_char_options_validator('bfqt', 'services'), options_list='--services',
                required=True)
        c.argument('hour', validator=process_metric_update_namespace, arg_type=get_enum_type(['true', 'false']))
        c.argument('minute', arg_type=get_enum_type(['true', 'false']))
        c.argument('api', arg_type=get_enum_type(['true', 'false']))
        c.argument('retention', type=int)

    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.')

    with self.argument_context('storage blob list') as c:
        c.argument('include', validator=validate_included_datasets)
        c.argument('num_results', type=int)
        c.ignore('marker')  # https://github.com/Azure/azure-cli/issues/3745

    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('blob.models#BlobPermissions')
        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_base_blob_service, 'container_name',
                                                                  'get_container_acl'))
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format(get_permission_help_string(t_blob_permissions)),
                   validator=get_permission_validator(t_blob_permissions))

    with self.argument_context('storage blob update') as c:
        t_blob_content_settings = self.get_sdk('blob.models#ContentSettings')
        c.register_content_settings_argument(t_blob_content_settings, update=True)

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

    with self.argument_context('storage blob url') as c:
        c.argument('protocol', arg_type=get_enum_type(['http', 'https'], 'https'), help='Protocol to use.')

    with self.argument_context('storage blob set-tier') as c:
        from azure.cli.command_modules.storage._validators import blob_tier_validator

        c.argument('blob_type', options_list=('--type', '-t'), arg_type=get_enum_type(('block', 'page')))
        c.argument('tier', validator=blob_tier_validator)
        c.argument('timeout', type=int)

    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 upload') as c:
        from ._validators import page_blob_tier_validator
        from .sdkutil import get_blob_types, get_blob_tier_names

        t_blob_content_settings = self.get_sdk('blob.models#ContentSettings')
        c.register_content_settings_argument(t_blob_content_settings, update=False)

        c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter())
        c.argument('max_connections', type=int)
        c.argument('blob_type', options_list=('--type', '-t'), validator=validate_blob_type,
                   arg_type=get_enum_type(get_blob_types()))
        c.argument('validate_content', action='store_true', min_api='2016-05-31')
        c.extra('no_progress', progress_type)
        c.extra('socket_timeout', socket_timeout_type)
        # TODO: Remove once #807 is complete. Smart Create Generation requires this parameter.
        # register_extra_cli_argument('storage blob upload', '_subscription_id', options_list=('--subscription',),
        #                              help=argparse.SUPPRESS)
        c.argument('tier', validator=page_blob_tier_validator,
                   arg_type=get_enum_type(get_blob_tier_names(self.cli_ctx, 'PremiumPageBlobTier')),
                   min_api='2017-04-17')

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

        t_blob_content_settings = self.get_sdk('blob.models#ContentSettings')
        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'), validator=process_blob_upload_batch_parameters)
        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('socket_timeout', socket_timeout_type)

    with self.argument_context('storage blob download') as c:
        c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter())
        c.argument('max_connections', type=int)
        c.argument('start_range', type=int)
        c.argument('end_range', type=int)
        c.argument('validate_content', action='store_true', min_api='2016-05-31')
        c.extra('no_progress', progress_type)
        c.extra('socket_timeout', socket_timeout_type)

    with self.argument_context('storage blob download-batch') as c:
        from azure.cli.command_modules.storage._validators import process_blob_download_batch_parameters

        c.ignore('source_container_name')
        c.argument('destination', options_list=('--destination', '-d'))
        c.argument('source', options_list=('--source', '-s'), validator=process_blob_download_batch_parameters)
        c.extra('no_progress', progress_type)
        c.extra('socket_timeout', socket_timeout_type)
        c.argument('max_connections', type=int,
                   help='Maximum number of parallel connections to use when the blob size exceeds 64MB.')

    with self.argument_context('storage blob delete') as c:
        from .sdkutil import get_delete_blob_snapshot_type_names
        c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names()))

    with self.argument_context('storage blob delete-batch') as c:
        from azure.cli.command_modules.storage._validators import process_blob_batch_source_parameters

        c.ignore('source_container_name')
        c.argument('source', options_list=('--source', '-s'), validator=process_blob_batch_source_parameters)
        c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names()),
                   help='Required if the blob has associated snapshots.')
        c.argument('lease_id', help='Required if the blob has an active lease.')

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

    with self.argument_context('storage blob copy') as c:
        for item in ['destination', 'source']:
            c.argument('{}_if_modified_since'.format(item), arg_group='Pre-condition')
            c.argument('{}_if_unmodified_since'.format(item), arg_group='Pre-condition')
            c.argument('{}_if_match'.format(item), arg_group='Pre-condition')
            c.argument('{}_if_none_match'.format(item), arg_group='Pre-condition')
        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.')
        c.argument('source_lease_id', arg_group='Copy Source')

    with self.argument_context('storage blob copy start') as c:
        from azure.cli.command_modules.storage._validators import validate_source_uri

        c.register_source_uri_arguments(validator=validate_source_uri)

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

        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')
        c.argument('prefix', validator=process_blob_copy_batch_namespace)

    with self.argument_context('storage blob incremental-copy start') as c:
        from azure.cli.command_modules.storage._validators import process_blob_source_uri

        c.register_source_uri_arguments(validator=process_blob_source_uri, blob_only=True)
        c.argument('destination_if_modified_since', arg_group='Pre-condition')
        c.argument('destination_if_unmodified_since', arg_group='Pre-condition')
        c.argument('destination_if_match', arg_group='Pre-condition')
        c.argument('destination_if_none_match', arg_group='Pre-condition')
        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.')
        c.argument('source_lease_id', arg_group='Copy Source')

    with self.argument_context('storage container') as c:
        from .sdkutil import get_container_access_type_names
        c.argument('container_name', container_name_type, options_list=('--name', '-n'))
        c.argument('public_access', validator=validate_container_public_access,
                   arg_type=get_enum_type(get_container_access_type_names()),
                   help='Specifies whether data in the container may be accessed publically. By default, container '
                        'data is private ("off") to the account owner. Use "blob" to allow public read access for '
                        'blobs. Use "container" to allow public read and list access to the entire container.')

    with self.argument_context('storage container create') as c:
        c.argument('container_name', container_name_type, options_list=('--name', '-n'), completer=None)
        c.argument('fail_on_exist', help='Throw an exception if the container already exists.')

    with self.argument_context('storage container delete') as c:
        c.argument('fail_not_exist', help='Throw an exception if the container does not exist.')

    with self.argument_context('storage container exists') as c:
        c.ignore('blob_name', 'snapshot')

    with self.argument_context('storage container set-permission') as c:
        c.ignore('signed_identifiers')

    with self.argument_context('storage container lease') as c:
        c.argument('container_name', container_name_type)

    with self.argument_context('storage container list') as c:
        c.ignore('marker')  # https://github.com/Azure/azure-cli/issues/3745

    with self.argument_context('storage container policy') as c:
        from .completers import get_storage_acl_name_completion_list
        t_container_permissions = self.get_sdk('blob.models#ContainerPermissions')

        c.argument('container_name', container_name_type)
        c.argument('policy_name', options_list=('--name', '-n'), help='The stored access policy name.',
                   completer=get_storage_acl_name_completion_list(t_base_blob_service, 'container_name',
                                                                  'get_container_acl'))
        help_str = 'Allowed values: {}. Can be combined'.format(get_permission_help_string(t_container_permissions))
        c.argument('permission', options_list='--permissions', help=help_str,
                   validator=get_permission_validator(t_container_permissions))

        c.argument('start', type=get_datetime_type(True),
                   help='start UTC datetime (Y-m-d\'T\'H:M:S\'Z\'). Defaults to time of request.')
        c.argument('expiry', type=get_datetime_type(True), help='expiration UTC datetime in (Y-m-d\'T\'H:M:S\'Z\')')

    for item in ['create', 'delete', 'list', 'show', 'update']:
        with self.argument_context('storage container policy {}'.format(item)) as c:
            c.extra('lease_id', options_list='--lease-id', help='The container lease ID.')

    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('blob.models#ContainerPermissions')
        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))

    with self.argument_context('storage container lease') as c:
        c.argument('lease_duration', type=int)
        c.argument('lease_break_period', type=int)

    with self.argument_context('storage share') as c:
        c.argument('share_name', share_name_type, options_list=('--name', '-n'))

    with self.argument_context('storage share list') as c:
        c.ignore('marker')  # https://github.com/Azure/azure-cli/issues/3745

    with self.argument_context('storage share exists') as c:
        c.ignore('directory_name', 'file_name')

    with self.argument_context('storage share policy') as c:
        from .completers import get_storage_acl_name_completion_list

        t_file_svc = self.get_sdk('file#FileService')
        t_share_permissions = self.get_sdk('file.models#SharePermissions')

        c.argument('container_name', share_name_type)
        c.argument('policy_name', options_list=('--name', '-n'), help='The stored access policy name.',
                   completer=get_storage_acl_name_completion_list(t_file_svc, 'container_name', 'get_share_acl'))

        help_str = 'Allowed values: {}. Can be combined'.format(get_permission_help_string(t_share_permissions))
        c.argument('permission', options_list='--permissions', help=help_str,
                   validator=get_permission_validator(t_share_permissions))

        c.argument('start', type=get_datetime_type(True),
                   help='start UTC datetime (Y-m-d\'T\'H:M:S\'Z\'). Defaults to time of request.')
        c.argument('expiry', type=get_datetime_type(True), help='expiration UTC datetime in (Y-m-d\'T\'H:M:S\'Z\')')

    with self.argument_context('storage share delete') as c:
        from .sdkutil import get_delete_file_snapshot_type_names
        c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_file_snapshot_type_names()),
                   help='Specify the deletion strategy when the share has snapshots.')

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

        t_share_permissions = self.get_sdk('file.models#SharePermissions')
        c.register_sas_arguments()
        c.argument('id', options_list='--policy-name',
                   help='The name of a stored access policy within the share\'s ACL.',
                   completer=get_storage_acl_name_completion_list(t_share_permissions, 'share_name', 'get_share_acl'))
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format(get_permission_help_string(t_share_permissions)),
                   validator=get_permission_validator(t_share_permissions))

    with self.argument_context('storage directory') as c:
        c.argument('directory_name', directory_type, options_list=('--name', '-n'))

    with self.argument_context('storage directory exists') as c:
        c.ignore('file_name')
        c.argument('directory_name', required=True)

    with self.argument_context('storage file') as c:
        c.argument('file_name', file_name_type, options_list=('--name', '-n'))
        c.argument('directory_name', directory_type, required=False)

    with self.argument_context('storage file copy') as c:
        c.argument('share_name', share_name_type, options_list=('--destination-share', '-s'),
                   help='Name of the destination share. The share must exist.')

    with self.argument_context('storage file copy start') as c:
        c.register_path_argument(options_list=('--destination-path', '-p'))

    with self.argument_context('storage file copy cancel') as c:
        c.register_path_argument(options_list=('--destination-path', '-p'))

    with self.argument_context('storage file delete') as c:
        c.register_path_argument()

    with self.argument_context('storage file download') as c:
        c.register_path_argument()
        c.argument('file_path', options_list=('--dest',), type=file_type, required=False,
                   help='Path of the file to write to. The source filename will be used if not specified.',
                   validator=process_file_download_namespace, completer=FilesCompleter())
        c.argument('path', validator=None)  # validator called manually from process_file_download_namespace
        c.extra('no_progress', progress_type)
        c.argument('max_connections', type=int)
        c.argument('start_range', type=int)
        c.argument('end_range', type=int)

    with self.argument_context('storage file exists') as c:
        c.register_path_argument()

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

        c.register_path_argument()
        c.register_sas_arguments()

        t_file_svc = self.get_sdk('file.fileservice#FileService')
        t_file_permissions = self.get_sdk('file.models#FilePermissions')
        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_file_svc, 'container_name', 'get_container_acl'))
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format(get_permission_help_string(t_file_permissions)),
                   validator=get_permission_validator(t_file_permissions))

    with self.argument_context('storage file list') as c:
        from .completers import dir_path_completer
        c.argument('directory_name', options_list=('--path', '-p'), help='The directory path within the file share.',
                   completer=dir_path_completer)

    with self.argument_context('storage file metadata show') as c:
        c.register_path_argument()

    with self.argument_context('storage file metadata update') as c:
        c.register_path_argument()

    with self.argument_context('storage file resize') as c:
        c.register_path_argument()
        c.argument('content_length', options_list='--size')

    with self.argument_context('storage file show') as c:
        c.register_path_argument()

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

        c.register_path_argument()
        c.register_content_settings_argument(t_file_content_settings, update=True)

    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')
        c.argument('local_file_path', options_list='--source', type=file_type, completer=FilesCompleter())
        c.extra('no_progress', progress_type)
        c.argument('max_connections', type=int)

    with self.argument_context('storage file url') as c:
        c.register_path_argument()
        c.argument('protocol', arg_type=get_enum_type(['http', 'https'], 'https'), help='Protocol to use.')

    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='Download 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')
        c.extra('no_progress', progress_type)

    with self.argument_context('storage file download-batch') as c:
        from ._validators import process_file_download_batch_parameters
        c.argument('source', options_list=('--source', '-s'), validator=process_file_download_batch_parameters)
        c.argument('destination', options_list=('--destination', '-d'))
        c.argument('max_connections', arg_group='Download Control', type=int)
        c.argument('validate_content', action='store_true', min_api='2016-05-31')
        c.extra('no_progress', progress_type)

    with self.argument_context('storage file delete-batch') as c:
        from ._validators import process_file_batch_source_parameters
        c.argument('source', options_list=('--source', '-s'), validator=process_file_batch_source_parameters)

    with self.argument_context('storage file copy start') as c:
        from azure.cli.command_modules.storage._validators import validate_source_uri

        c.register_source_uri_arguments(validator=validate_source_uri)

    with self.argument_context('storage file 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 cors list') as c:
        c.extra('services', validator=get_char_options_validator('bfqt', 'services'), default='bqft',
                options_list='--services', required=False)

    with self.argument_context('storage cors add') as c:
        c.extra('services', validator=get_char_options_validator('bfqt', 'services'), required=True,
                options_list='--services')
        c.argument('max_age')
        c.argument('origins', nargs='+')
        c.argument('methods', nargs='+',
                   arg_type=get_enum_type(['DELETE', 'GET', 'HEAD', 'MERGE', 'POST', 'OPTIONS', 'PUT']))
        c.argument('allowed_headers', nargs='+')
        c.argument('exposed_headers', nargs='+')

    with self.argument_context('storage cors clear') as c:
        c.extra('services', validator=get_char_options_validator('bfqt', 'services'), required=True,
                options_list='--services')

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

        t_queue_permissions = self.get_sdk('queue.models#QueuePermissions')

        c.register_sas_arguments()

        c.argument('id', options_list='--policy-name',
                   help='The name of a stored access policy within the share\'s ACL.',
                   completer=get_storage_acl_name_completion_list(t_queue_permissions, 'queue_name', 'get_queue_acl'))
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format(get_permission_help_string(t_queue_permissions)),
                   validator=get_permission_validator(t_queue_permissions))

    with self.argument_context('storage queue') as c:
        c.argument('queue_name', queue_name_type, options_list=('--name', '-n'))

    with self.argument_context('storage queue create') as c:
        c.argument('queue_name', queue_name_type, options_list=('--name', '-n'), completer=None)

    with self.argument_context('storage queue policy') as c:
        from .completers import get_storage_acl_name_completion_list

        t_queue_permissions = self.get_sdk('queue.models#QueuePermissions')

        c.argument('container_name', queue_name_type)
        c.argument('policy_name', options_list=('--name', '-n'), help='The stored access policy name.',
                   completer=get_storage_acl_name_completion_list(t_queue_service, 'container_name', 'get_queue_acl'))

        help_str = 'Allowed values: {}. Can be combined'.format(get_permission_help_string(t_queue_permissions))
        c.argument('permission', options_list='--permissions', help=help_str,
                   validator=get_permission_validator(t_queue_permissions))

        c.argument('start', type=get_datetime_type(True),
                   help='start UTC datetime (Y-m-d\'T\'H:M:S\'Z\'). Defaults to time of request.')
        c.argument('expiry', type=get_datetime_type(True), help='expiration UTC datetime in (Y-m-d\'T\'H:M:S\'Z\')')

    with self.argument_context('storage message') as c:
        c.argument('queue_name', queue_name_type)
        c.argument('message_id', options_list='--id')
        c.argument('content', type=unicode_string, help='Message content, up to 64KB in size.')

    with self.argument_context('storage table') as c:
        c.argument('table_name', table_name_type, options_list=('--name', '-n'))

    with self.argument_context('storage table create') as c:
        c.argument('table_name', table_name_type, options_list=('--name', '-n'), completer=None)
        c.argument('fail_on_exist', help='Throw an exception if the table already exists.')

    with self.argument_context('storage table policy') as c:
        from ._validators import table_permission_validator
        from .completers import get_storage_acl_name_completion_list

        c.argument('container_name', table_name_type)
        c.argument('policy_name', options_list=('--name', '-n'), help='The stored access policy name.',
                   completer=get_storage_acl_name_completion_list(t_table_service, 'table_name', 'get_table_acl'))

        help_str = 'Allowed values: (r)ead/query (a)dd (u)pdate (d)elete. Can be combined.'
        c.argument('permission', options_list='--permissions', help=help_str, validator=table_permission_validator)

        c.argument('start', type=get_datetime_type(True),
                   help='start UTC datetime (Y-m-d\'T\'H:M:S\'Z\'). Defaults to time of request.')
        c.argument('expiry', type=get_datetime_type(True), help='expiration UTC datetime in (Y-m-d\'T\'H:M:S\'Z\')')

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

        c.register_sas_arguments()
        c.argument('id', options_list='--policy-name',
                   help='The name of a stored access policy within the table\'s ACL.',
                   completer=get_storage_acl_name_completion_list(t_table_service, 'table_name', 'get_table_acl'))
        c.argument('permission', options_list='--permissions',
                   help=sas_help.format('(r)ead/query (a)dd (u)pdate (d)elete'),
                   validator=table_permission_validator)

    with self.argument_context('storage entity') as c:
        c.ignore('property_resolver')
        c.argument('entity', options_list=('--entity', '-e'), validator=validate_entity, nargs='+')
        c.argument('select', nargs='+', validator=validate_select,
                   help='Space-separated list of properties to return for each entity.')

    with self.argument_context('storage entity insert') as c:
        c.argument('if_exists', arg_type=get_enum_type(['fail', 'merge', 'replace']))

    with self.argument_context('storage entity query') as c:
        c.argument('accept', default='minimal', validator=validate_table_payload_format,
                   arg_type=get_enum_type(['none', 'minimal', 'full']),
                   help='Specifies how much metadata to include in the response payload.')
        c.argument('marker', validator=validate_marker, nargs='+')
示例#29
0
def load_arguments(self, _):

    with self.argument_context('spring-cloud') as c:
        c.argument('resource_group', arg_type=resource_group_name_type)
        c.argument('name', options_list=[
            '--name', '-n'], help='Name of Azure Spring Cloud.')

    with self.argument_context('spring-cloud create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=validate_location)
        c.argument('sku', type=str, validator=validate_sku, help='Name of SKU, the value is "Basic" or "Standard"')
        c.argument('reserved_cidr_range', help='Comma-separated list of IP address ranges in CIDR format. The IP ranges are reserved to host underlying Azure Spring Cloud infrastructure, which should be 3 at least /16 unused IP ranges, must not overlap with any Subnet IP ranges.', validator=validate_vnet_required_parameters)
        c.argument('vnet', help='The name or ID of an existing Virtual Network into which to deploy the Spring Cloud instance.', validator=validate_vnet_required_parameters)
        c.argument('app_subnet', help='The name or ID of an existing subnet in "vnet" into which to deploy the Spring Cloud app. Required when deploying into a Virtual Network. Smaller subnet sizes are supported, please refer: https://aka.ms/azure-spring-cloud-smaller-subnet-vnet-docs', validator=validate_vnet_required_parameters)
        c.argument('service_runtime_subnet', options_list=['--service-runtime-subnet', '--svc-subnet'], help='The name or ID of an existing subnet in "vnet" into which to deploy the Spring Cloud service runtime. Required when deploying into a Virtual Network.', validator=validate_vnet)
        c.argument('service_runtime_network_resource_group', options_list=['--service-runtime-network-resource-group', '--svc-nrg'], help='The resource group where all network resources for Azure Spring Cloud service runtime will be created in.', validator=validate_node_resource_group)
        c.argument('app_network_resource_group', options_list=['--app-network-resource-group', '--app-nrg'], help='The resource group where all network resources for apps will be created in.', validator=validate_node_resource_group)
        c.argument('enable_java_agent', is_preview=True, arg_type=get_three_state_flag(), help="Enable java in-process agent", validator=validate_java_agent_parameters)
    with self.argument_context('spring-cloud update') as c:
        c.argument('sku', type=str, validator=validate_sku, help='Name of SKU, the value is "Basic" or "Standard"')

    for scope in ['spring-cloud create', 'spring-cloud update']:
        with self.argument_context(scope) as c:
            c.argument('app_insights_key',
                       help="Instrumentation key of the existing Application Insights.",
                       validator=validate_tracing_parameters)
            c.argument('app_insights',
                       help="Name of the existing Application Insights in the same Resource Group. Or Resource ID of the existing Application Insights in a different Resource Group.",
                       validator=validate_tracing_parameters)
            c.argument('disable_distributed_tracing',
                       arg_type=get_three_state_flag(),
                       help="Disable distributed tracing, if not disabled and no existing Application Insights specified with --app-insights-key or --app-insights, will create a new Application Insights instance in the same resource group.",
                       validator=validate_tracing_parameters,
                       deprecate_info=c.deprecate(target='--disable-distributed-tracing', redirect='--disable-app-insights', hide=True))
            c.argument('disable_app_insights',
                       arg_type=get_three_state_flag(),
                       help="Disable Application Insights, if not disabled and no existing Application Insights specified with --app-insights-key or --app-insights, will create a new Application Insights instance in the same resource group.",
                       validator=validate_tracing_parameters)
            c.argument('tags', arg_type=tags_type)

    with self.argument_context('spring-cloud test-endpoint renew-key') as c:
        c.argument('type', type=str, arg_type=get_enum_type(
            TestKeyType), help='Type of test-endpoint key')

    with self.argument_context('spring-cloud app') as c:
        c.argument('service', service_name_type)
        c.argument('name', name_type, help='Name of app.')

    with self.argument_context('spring-cloud app create') as c:
        c.argument('assign_endpoint', arg_type=get_three_state_flag(),
                   help='If true, assign endpoint URL for direct access.', default=False,
                   options_list=['--assign-endpoint', c.deprecate(target='--is-public', redirect='--assign-endpoint', hide=True)])
        c.argument('assign_identity', arg_type=get_three_state_flag(),
                   help='If true, assign managed service identity.')
        c.argument('cpu', type=str, default="1",
                   help='CPU resource quantity. Should be 500m or number of CPU cores.')
        c.argument('memory', type=str, default="1Gi",
                   help='Memory resource quantity. Should be 512Mi or #Gi, e.g., 1Gi, 3Gi.')
        c.argument('instance_count', type=int,
                   default=1, help='Number of instance.', validator=validate_instance_count)

    with self.argument_context('spring-cloud app update') as c:
        c.argument('assign_endpoint', arg_type=get_three_state_flag(),
                   help='If true, assign endpoint URL for direct access.',
                   options_list=['--assign-endpoint', c.deprecate(target='--is-public', redirect='--assign-endpoint', hide=True)])
        c.argument('https_only', arg_type=get_three_state_flag(), help='If true, access app via https', default=False)
        c.argument('enable_end_to_end_tls', arg_type=get_three_state_flag(), help='If true, enable end to end tls')

    for scope in ['spring-cloud app update', 'spring-cloud app start', 'spring-cloud app stop', 'spring-cloud app restart', 'spring-cloud app deploy', 'spring-cloud app scale', 'spring-cloud app set-deployment', 'spring-cloud app show-deploy-log']:
        with self.argument_context(scope) as c:
            c.argument('deployment', options_list=[
                '--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=validate_deployment_name)
            c.argument('main_entry', options_list=[
                '--main-entry', '-m'], help="The path to the .NET executable relative to zip root.")

    with self.argument_context('spring-cloud app identity assign') as c:
        c.argument('scope', help="The scope the managed identity has access to")
        c.argument('role', help="Role name or id the managed identity will be assigned")

    def prepare_logs_argument(c):
        '''`app log tail` is deprecated. `app logs` is the new choice. They share the same command processor.'''
        c.argument('instance', options_list=['--instance', '-i'], help='Name of an existing instance of the deployment.')
        c.argument('lines', type=int, help='Number of lines to show. Maximum is 10000', validator=validate_log_lines)
        c.argument('follow', options_list=['--follow ', '-f'], help='Specify if the logs should be streamed.', action='store_true')
        c.argument('since', help='Only return logs newer than a relative duration like 5s, 2m, or 1h. Maximum is 1h', validator=validate_log_since)
        c.argument('limit', type=int, help='Maximum kilobytes of logs to return. Ceiling number is 2048.', validator=validate_log_limit)
        c.argument('deployment', options_list=[
            '--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=validate_deployment_name)
        c.argument('format_json', nargs='?', const='{timestamp} {level:>5} [{thread:>15.15}] {logger{39}:<40.40}: {message}\n{stackTrace}',
                   help='Format JSON logs if structured log is enabled')

    with self.argument_context('spring-cloud app logs') as c:
        prepare_logs_argument(c)

    with self.argument_context('spring-cloud app log tail') as c:
        prepare_logs_argument(c)

    with self.argument_context('spring-cloud app set-deployment') as c:
        c.argument('deployment', options_list=[
            '--deployment', '-d'], help='Name of an existing deployment of the app.', validator=validate_deployment_name)

    for scope in ['spring-cloud app create', 'spring-cloud app update']:
        with self.argument_context(scope) as c:
            c.argument('enable_persistent_storage', arg_type=get_three_state_flag(),
                       help='If true, mount a 50G (Standard Pricing tier) or 1G (Basic Pricing tier) disk with default path.')

    for scope in ['spring-cloud app update', 'spring-cloud app deployment create', 'spring-cloud app deploy', 'spring-cloud app create']:
        with self.argument_context(scope) as c:
            c.argument('runtime_version', arg_type=get_enum_type(RuntimeVersion),
                       help='Runtime version of used language')
            c.argument('jvm_options', type=str, validator=validate_jvm_options,
                       help="A string containing jvm options, use '=' instead of ' ' for this argument to avoid bash parse error, eg: --jvm-options='-Xms1024m -Xmx2048m'")
            c.argument('env', env_type)

    with self.argument_context('spring-cloud app scale') as c:
        c.argument('cpu', type=str, help='CPU resource quantity. Should be 500m or number of CPU cores.')
        c.argument('memory', type=str, help='Memory resource quantity. Should be 512Mi or #Gi, e.g., 1Gi, 3Gi.')
        c.argument('instance_count', type=int, help='Number of instance.', validator=validate_instance_count)

    for scope in ['spring-cloud app deploy', 'spring-cloud app deployment create']:
        with self.argument_context(scope) as c:
            c.argument(
                'artifact_path', options_list=[
                    '--artifact-path', '--jar-path', '-p'], help='If provided, deploy pre-built artifact (jar or netcore zip), otherwise deploy current folder as tar.')
            c.argument(
                'main_entry', options_list=[
                    '--main-entry', '-m'], help="A string containing the path to the .NET executable relative to zip root.")
            c.argument(
                'target_module', help='Child module to be deployed, required for multiple jar packages built from source code.')
            c.argument(
                'version', help='Deployment version, keep unchanged if not set.')

    with self.argument_context('spring-cloud app deployment create') as c:
        c.argument('skip_clone_settings', help='Create staging deployment will automatically copy settings from production deployment.',
                   action='store_true')
        c.argument('cpu', type=str, help='CPU resource quantity. Should be 500m or number of CPU cores.')
        c.argument('memory', type=str, help='Memory resource quantity. Should be 512Mi or #Gi, e.g., 1Gi, 3Gi.')
        c.argument('instance_count', type=int, help='Number of instance.', validator=validate_instance_count)

    with self.argument_context('spring-cloud app deployment') as c:
        c.argument('app', app_name_type, help='Name of app.',
                   validator=validate_app_name)
        c.argument('name', name_type, help='Name of deployment.')

    with self.argument_context('spring-cloud app binding') as c:
        c.argument('app', app_name_type, help='Name of app.',
                   validator=validate_app_name)
        c.argument('name', name_type, help='Name of service binding.')

    for scope in ['spring-cloud app binding cosmos add', 'spring-cloud app binding mysql add', 'spring-cloud app binding redis add']:
        with self.argument_context(scope) as c:
            c.argument('resource_id', validator=validate_resource_id,
                       help='Azure resource ID of the service to bind with.')

    for scope in ['spring-cloud app binding cosmos add', 'spring-cloud app binding cosmos update']:
        with self.argument_context(scope) as c:
            c.argument(
                'database_name', help='Name of database. Required for mongo, sql, gremlin')
            c.argument(
                'key_space', help='Cassandra key space. Required for cassandra')
            c.argument('collection_name',
                       help='Name of collection. Required for gremlin')

    with self.argument_context('spring-cloud app binding cosmos add') as c:
        c.argument('api_type', help='Type of API.', arg_type=get_enum_type(
            ApiType), validator=validate_cosmos_type)

    for scope in ['spring-cloud app binding mysql add', 'spring-cloud app binding mysql update']:
        with self.argument_context(scope) as c:
            c.argument('key', help='API key of the service.')
            c.argument('username', help='Username of the database')
            c.argument('database_name', help='Database name')

    for scope in ['spring-cloud app binding redis add', 'spring-cloud app binding redis update']:
        with self.argument_context(scope) as c:
            c.argument('key', help='Api key of the service.')
            c.argument('disable_ssl', arg_type=get_three_state_flag(), help='If true, disable SSL. If false, enable SSL.', default=False)

    with self.argument_context('spring-cloud config-server set') as c:
        c.argument('config_file',
                   help='A yaml file path for the configuration of Spring Cloud config server')

    for scope in ['spring-cloud config-server git set', 'spring-cloud config-server git repo add', 'spring-cloud config-server git repo update']:
        with self.argument_context(scope) as c:
            c.argument('uri', help='Uri of the added config.')
            c.argument('label', help='Label of the added config.')
            c.argument(
                'search_paths', help='search_paths of the added config, use , as delimiter for multiple paths.')
            c.argument('username', help='Username of the added config.')
            c.argument('password', help='Password of the added config.')
            c.argument('host_key', help='Host key of the added config.')
            c.argument('host_key_algorithm',
                       help='Host key algorithm of the added config.')
            c.argument('private_key', help='Private_key of the added config.')
            c.argument('strict_host_key_checking',
                       help='Strict_host_key_checking of the added config.')

    for scope in ['spring-cloud config-server git repo add', 'spring-cloud config-server git repo update', 'spring-cloud config-server git repo remove']:
        with self.argument_context(scope) as c:
            c.argument('repo_name', help='Name of the repo.')

    for scope in ['spring-cloud config-server git repo add', 'spring-cloud config-server git repo update']:
        with self.argument_context(scope) as c:
            c.argument(
                'pattern', help='Pattern of the repo, use , as delimiter for multiple patterns')

    with self.argument_context('spring-cloud test-endpoint list') as c:
        c.argument('app', app_name_type, help='Name of app.',
                   validator=validate_app_name)
        c.argument('deployment', options_list=[
            '--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=validate_deployment_name)

    with self.argument_context('spring-cloud certificate') as c:
        c.argument('service', service_name_type)
        c.argument('name', name_type, help='Name of certificate.')

    with self.argument_context('spring-cloud certificate add') as c:
        c.argument('vault_uri', help='The key vault uri where store the certificate')
        c.argument('vault_certificate_name', help='The certificate name in key vault')

    with self.argument_context('spring-cloud app custom-domain') as c:
        c.argument('service', service_name_type)
        c.argument('app', app_name_type, help='Name of app.', validator=validate_app_name)
        c.argument('domain_name', help='Name of custom domain.')

    with self.argument_context('spring-cloud app custom-domain bind') as c:
        c.argument('certificate', type=str, help='Certificate name in Azure Spring Cloud.')
        c.argument('enable_end_to_end_tls', arg_type=get_three_state_flag(), help='If true, enable end to end tls')

    with self.argument_context('spring-cloud app custom-domain update') as c:
        c.argument('certificate', help='Certificate name in Azure Spring Cloud.')
        c.argument('enable_end_to_end_tls', arg_type=get_three_state_flag(), help='If true, enable end to end tls')

    with self.argument_context('spring-cloud app-insights update') as c:
        c.argument('app_insights_key',
                   help="Instrumentation key of the existing Application Insights",
                   validator=validate_app_insights_parameters)
        c.argument('app_insights',
                   help="Name of the existing Application Insights in the same Resource Group. Or Resource ID of the existing Application Insights in a different Resource Group.",
                   validator=validate_app_insights_parameters)
        c.argument('sampling_rate',
                   type=float,
                   help="Sampling Rate of application insights. Maximum is 100.",
                   validator=validate_app_insights_parameters)
        c.argument('disable',
                   arg_type=get_three_state_flag(),
                   help="Disable Application Insights.",
                   validator=validate_app_insights_parameters)
示例#30
0
def load_arguments(self, _):  # pylint: disable=too-many-statements
    with self.argument_context('acr') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('tags', arg_type=tags_type)
        c.argument('registry_name', options_list=['--name', '-n'], help='The name of the container registry. You can configure the default registry name using `az configure --defaults acr=<registry name>`', completer=get_resource_name_completion_list(REGISTRY_RESOURCE_TYPE), configured_default='acr')
        c.argument('storage_account_name', help='Provide the name of an existing storage account if you\'re recreating a container registry over a previous registry created storage account. Only applicable to Classic SKU.', completer=get_resource_name_completion_list(STORAGE_RESOURCE_TYPE))
        c.argument('sku', help='The SKU of the container registry', choices=MANAGED_REGISTRY_SKU + CLASSIC_REGISTRY_SKU)
        c.argument('admin_enabled', help='Indicates whether the admin user is enabled', arg_type=get_three_state_flag())
        c.argument('password_name', help='The name of password to regenerate', choices=['password', 'password2'])
        c.argument('username', options_list=['--username', '-u'], help='The username used to log into a container registry')
        c.argument('password', options_list=['--password', '-p'], help='The password used to log into a container registry')
        c.argument('image_names', options_list=['--image', '-t'], help="The image repository and optionally a tag in the 'repository:tag' format.", action='append')
        c.argument('docker_file_path', options_list=['--file', '-f'], help="The relative path of the the docker file to the source code root folder.")
        c.argument('build_arg', help="Build argument in 'name[=value]' format.", action='append', validator=validate_build_arg)
        c.argument('secret_build_arg', help="Secret build argument in 'name[=value]' format.", action='append', validator=validate_secret_build_arg)
        c.argument('no_push', help="Indicates whether the image built should be pushed to the registry.", arg_type=get_three_state_flag())
        c.argument('no_logs', help="Do not show logs after successfully queuing the build.", action='store_true')

    with self.argument_context('acr repository delete') as c:
        c.argument('manifest', nargs='?', required=False, const='', default=None, help=argparse.SUPPRESS)
        c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation')
        c.argument('repository', help="The name of the repository to delete")
        c.argument('tag', help=argparse.SUPPRESS)
        c.argument('image', help="The name of the image to delete. May include a tag in the format 'name:tag' or digest in the format 'name@digest'.")

    with self.argument_context('acr repository untag') as c:
        c.argument('image', help="The name of the image to untag. May include a tag in the format 'name:tag'.")

    with self.argument_context('acr repository show-manifests') as c:
        c.argument('repository', help='The repository to obtain manifests from.')

    with self.argument_context('acr repository show-tags') as c:
        c.argument('repository', help='The repository to obtain tags from.')

    with self.argument_context('acr create') as c:
        c.argument('registry_name', completer=None, validator=validate_registry_name)
        c.argument('deployment_name', arg_type=deployment_name_type, validator=None)
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)

    with self.argument_context('acr check-name') as c:
        c.argument('registry_name', completer=None)

    with self.argument_context('acr webhook') as c:
        c.argument('registry_name', options_list=['--registry', '-r'])
        c.argument('webhook_name', options_list=['--name', '-n'], help='The name of the webhook', completer=get_resource_name_completion_list(WEBHOOK_RESOURCE_TYPE))
        c.argument('uri', help='The service URI for the webhook to post notifications.')
        c.argument('headers', nargs='+', help="Space-separated custom headers in 'key[=value]' format that will be added to the webhook notifications. Use {} to clear existing headers.".format(quotes), validator=validate_headers)
        c.argument('actions', nargs='+', help='Space-separated list of actions that trigger the webhook to post notifications.', choices=['push', 'delete'])
        c.argument('status', help='Indicates whether the webhook is enabled.', choices=['enabled', 'disabled'])
        c.argument('scope', help="The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means events for all repositories.")

    with self.argument_context('acr webhook create') as c:
        c.argument('webhook_name', completer=None)

    with self.argument_context('acr replication') as c:
        c.argument('registry_name', options_list=['--registry', '-r'])
        c.argument('replication_name', options_list=['--name', '-n'], help='The name of the replication.', completer=get_resource_name_completion_list(REPLICATION_RESOURCE_TYPE))

    with self.argument_context('acr replication create') as c:
        c.argument('replication_name', help='The name of the replication. Default to the location name.', completer=None)

    with self.argument_context('acr build') as c:
        c.argument('registry_name', options_list=['--registry', '-r'])
        c.positional('source_location', help="The local source code directory path (e.g., './src') or the URL to a git repository (e.g., 'https://github.com/Azure-Samples/acr-build-helloworld-node.git') or a remote tarball (e.g., 'http://server/context.tar.gz').", completer=FilesCompleter())
        c.argument('timeout', help='The build timeout in seconds.')

    with self.argument_context('acr build-task') as c:
        c.argument('registry_name', options_list=['--registry', '-r'])
        # build task parameters
        c.argument('build_task_name', options_list=['--name', '-n'], help='The name of the build task.', completer=get_resource_name_completion_list(BUILD_TASK_RESOURCE_TYPE))
        c.argument('alias', help='The alternative name for build task. Default to the build task name.')
        c.argument('status', help='The current status of build task.', choices=[BuildTaskStatus.enabled.value, BuildTaskStatus.disabled.value])
        c.argument('os_type', options_list=['--os'], help='The operating system type required for the build.', choices=[OsType.linux.value, OsType.windows.value])
        c.argument('cpu', type=int, help='The CPU configuration in terms of number of cores required for the build.')
        c.argument('timeout', type=int, help='Build timeout in seconds.')
        c.argument('repository_url', options_list=['--context', '-c'], help="The full URL to the source code respository.")
        c.argument('commit_trigger_enabled', help="Indicates whether the source control commit trigger is enabled.", arg_type=get_three_state_flag())
        c.argument('git_access_token', help="The access token used to access the source control provider.")
        # build step parameters
        c.argument('step_name', help='The name of the build step.', completer=get_resource_name_completion_list(BUILD_STEP_RESOURCE_TYPE))
        c.argument('branch', help="The source control branch name.")
        c.argument('no_cache', help='Indicates whether the image cache is enabled.', arg_type=get_three_state_flag())
        c.argument('base_image_trigger', help="The type of the auto trigger for base image dependency updates.", choices=[BaseImageTriggerType.all.value,
                                                                                                                          BaseImageTriggerType.runtime.value,
                                                                                                                          BaseImageTriggerType.none.value])
        # build parameters
        c.argument('top', help='Limit the number of latest builds in the results.')
        c.argument('build_id', help='The unique build identifier.')
        c.argument('build_status', help='The current status of build.', choices=[BuildStatus.queued.value,
                                                                                 BuildStatus.started.value,
                                                                                 BuildStatus.running.value,
                                                                                 BuildStatus.succeeded.value,
                                                                                 BuildStatus.failed.value,
                                                                                 BuildStatus.canceled.value,
                                                                                 BuildStatus.error.value,
                                                                                 BuildStatus.timeout.value])

    with self.argument_context('acr build-task create') as c:
        c.argument('build_task_name', completer=None)
示例#31
0
def load_arguments(self, _):

    from azext_front_door.vendored_sdks.models import (
        PolicyMode, FrontDoorProtocol, FrontDoorHealthProbeMethod, FrontDoorCertificateSource, FrontDoorQuery, ActionType, RuleType, TransformType,
        FrontDoorRedirectType, FrontDoorRedirectProtocol, MinimumTLSVersion, Transform, HeaderActionType, RulesEngineOperator, RulesEngineMatchVariable,
        FrontDoorForwardingProtocol, MatchProcessingBehavior
    )

    frontdoor_name_type = CLIArgumentType(options_list=['--front-door-name', '-f'], help='Name of the Front Door.', completer=get_resource_name_completion_list('Microsoft.Network/frontdoors'), id_part='name')
    waf_policy_name_type = CLIArgumentType(options_list='--policy-name', help='Name of the WAF policy.', completer=get_resource_name_completion_list('Microsoft.Network/frontDoorWebApplicationFirewallPolicies'), id_part='name')
    rules_engine_name_type = CLIArgumentType(options_list=['--rules-engine-name', '-r'], help='Name of the Rules Engine.', completer=get_fd_subresource_completion_list('rules_engines'), id_part='child_name_1')

    # region FrontDoors
    fd_subresources = [
        {'name': 'backend-pool', 'display': 'backend pool', 'ref': 'backend_pools'},
        {'name': 'frontend-endpoint', 'display': 'frontend endpoint', 'ref': 'frontend_endpoints'},
        {'name': 'load-balancing', 'display': 'load balancing settings', 'ref': 'load_balancing_settings'},
        {'name': 'probe', 'display': 'health probe', 'ref': 'health_probe_settings'},
        {'name': 'routing-rule', 'display': 'routing rule', 'ref': 'routing_rules'}
    ]
    for item in fd_subresources:
        with self.argument_context('network front-door {}'.format(item['name'])) as c:
            c.argument('item_name', options_list=['--name', '-n'], help='Name of the {}'.format(item['display']), completer=get_fd_subresource_completion_list(item['ref']), id_part='child_name_1')
            c.argument('front_door_name', frontdoor_name_type, id_part=None)
            c.argument('resource_name', frontdoor_name_type, id_part=None)

    with self.argument_context('network front-door') as c:
        c.argument('front_door_name', frontdoor_name_type, options_list=['--name', '-n'])
        c.argument('friendly_name', help='Friendly name of the Front Door.')
        c.argument('tags', tags_type)
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create in a disabled state.')
        c.argument('enabled', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Enabled status.')

    with self.argument_context('network front-door', arg_group='Frontend Endpoint') as c:
        c.argument('frontend_host_name', help='Domain name of the frontend endpoint.')

    with self.argument_context('network front-door', arg_group='HTTPS') as c:
        c.argument('certificate_source', arg_type=get_enum_type(FrontDoorCertificateSource), help='Certificate source to enable HTTPS.')
        c.argument('secret_name', help='The name of the Key Vault secret representing the full certificate PFX')
        c.argument('secret_version', help='The version of the Key Vault secret representing the full certificate PFX')
        c.argument('vault_id', help='The resource id of the Key Vault containing the SSL certificate')
        c.argument('minimum_tls_version', arg_type=get_enum_type(MinimumTLSVersion), help='The minimum TLS version required from the clients to establish an SSL handshake with Front Door.')

    with self.argument_context('network front-door', arg_group='BackendPools Settings') as c:
        c.argument('enforce_certificate_name_check', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Whether to disable certificate name check on HTTPS requests to all backend pools. No effect on non-HTTPS requests.')
        c.argument('send_recv_timeout', type=int, help='Send and receive timeout in seconds on forwarding request to the backend. When timeout is reached, the request fails and returns.')

    with self.argument_context('network front-door', arg_group='Backend') as c:
        c.argument('backend_address', help='FQDN of the backend endpoint.')
        c.argument('backend_host_header', help='Host header sent to the backend.')

    with self.argument_context('network front-door', arg_group='Probe Setting') as c:
        c.argument('probe_path', options_list='--path', help='Path to probe.')
        c.argument('probe_protocol', options_list='--protocol', arg_type=get_enum_type(FrontDoorProtocol), help='Protocol to use for sending probes.')
        c.argument('probe_interval', options_list='--interval', type=int, help='Interval in seconds between probes.')
        c.argument('enabled', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Enabled status.')
        c.argument('probe_method', options_list='--probeMethod', arg_type=get_enum_type(FrontDoorHealthProbeMethod), help='Configures which HTTP method to use to probe the backends defined under backendPools.')

    with self.argument_context('network front-door', arg_group='Routing Rule') as c:
        c.argument('accepted_protocols', nargs='+', help='Space-separated list of protocols to accept. Default: Http')
        c.argument('patterns_to_match', options_list='--patterns', nargs='+', help='Space-separated list of patterns to match. Default: \'/*\'.')
        c.argument('forwarding_protocol', arg_type=get_enum_type(FrontDoorForwardingProtocol), help='Protocol to use for forwarding traffic.')
        c.argument('route_type', arg_type=get_enum_type(RouteType), help='Route type to define how Front Door should handle requests for this route i.e. forward them to a backend or redirect the users to a different URL.')

    with self.argument_context('network front-door purge-endpoint') as c:
        c.argument('content_paths', nargs='+')

    with self.argument_context('network front-door backend-pool') as c:
        c.argument('load_balancing_settings', options_list='--load-balancing', help='Name or ID of the load balancing settings.', validator=validate_load_balancing_settings)
        c.argument('probe_settings', options_list='--probe', help='Name or ID of the probe settings.', validator=validate_probe_settings)

    with self.argument_context('network front-door frontend-endpoint') as c:
        c.argument('host_name', help='Domain name of the frontend endpoint.')
        c.argument('session_affinity_enabled', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Whether to allow session affinity on this host.')
        c.argument('session_affinity_ttl', help='The TTL to use in seconds for session affinity.', type=int)
        c.argument('waf_policy', help='Name or ID of a web application firewall policy.', validator=validate_waf_policy)

    with self.argument_context('network front-door load-balancing') as c:
        c.argument('additional_latency', type=int, help='The additional latency in milliseconds for probes to fall in the lowest latency bucket.')
        c.argument('sample_size', type=int, help='The number of samples to consider for load balancing decisions.')
        c.argument('successful_samples_required', type=int, help='The number of samples within the sample period that must succeed.')

    with self.argument_context('network front-door probe') as c:
        c.argument('path', help='Path to probe.')
        c.argument('protocol', arg_type=get_enum_type(FrontDoorProtocol), help='Protocol to use for sending probes.')
        c.argument('interval', help='Interval in seconds between probes.')

    for scope in ['backend-pool', 'backend-pool backend']:
        arg_group = 'Backend' if scope == 'backend-pool' else None
        with self.argument_context('network front-door {}'.format(scope), arg_group=arg_group) as c:
            c.argument('address', help='FQDN of the backend endpoint.')
            c.argument('host_header', help='Host header sent to the backend.')
            c.argument('priority', type=int, help='Priority to use for load balancing. Higher priorities will not be used for load balancing if any lower priority backend is healthy.')
            c.argument('http_port', type=int, help='HTTP TCP port number.')
            c.argument('https_port', type=int, help='HTTPS TCP port number.')
            c.argument('weight', type=int, help='Weight of this endpoint for load balancing purposes.')
            c.argument('private_link_alias', help='The Alias of the Private Link resource. Populating this optional field indicates that this backend is \'Private\'.')
            c.argument('private_link_resource_id', help='The Resource Id of the Private Link. Populating this optional field indicates that this backend is \'Private\'.')
            c.argument('private_link_location', help='The location of the Private Link resource. Required only if \'privateLinkResourceId\' is populated.')
            c.argument('private_link_approval_message', help='A custom message to be included in the approval request to connect to the Private Link.')
            c.argument('backend_host_header', help='Host header sent to the backend.')
            c.argument('backend_pool_name', options_list='--pool-name', help='Name of the backend pool.')
            c.argument('index', type=int, help='Index of the backend to remove (starting with 1).')

    with self.argument_context('network front-door routing-rule', arg_group=None) as c:
        c.argument('accepted_protocols', nargs='+', help='Space-separated list of protocols to accept. Default: Http')
        c.argument('patterns_to_match', options_list='--patterns', nargs='+', help='Space-separated list of patterns to match. Default: \'/*\'.')
        c.argument('rules_engine', help='Name or ID of a Rules Engine configuration. To unlink property, \"--remove rulesEngine\"', validator=validate_rules_engine)
        c.argument('frontend_endpoints', help='Space-separated list of frontend endpoint names or IDs.', nargs='+', validator=validate_frontend_endpoints)
    with self.argument_context('network front-door routing-rule', arg_group='Forward Routing Rule') as c:
        c.argument('backend_pool', help="Name or ID of a backend pool. It's required to create a Forward routing rule.", validator=validate_backend_pool)
        c.argument('forwarding_protocol', arg_type=get_enum_type(FrontDoorForwardingProtocol), help='Protocol to use for forwarding traffic.')
        c.argument('custom_forwarding_path', help='Custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path.')
        c.argument('caching', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=False), help='Whether to enable caching for this route.')
        c.argument('cache_duration', help='The duration for which the content needs to be cached. Allowed format is ISO 8601 duration')
        c.argument('dynamic_compression', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Use dynamic compression for cached content.')
        c.argument('query_parameter_strip_directive', arg_type=get_enum_type(FrontDoorQuery), help='Treatment of URL query terms when forming the cache key.')
        c.argument('query_parameters', help='Query parameters to include or exclude (comma separated) when using query-parameter-strip-directive type StripAllExcept or StripOnly respectively.')
    with self.argument_context('network front-door routing-rule', arg_group='Redirect Routing Rule') as c:
        c.argument('redirect_type', arg_type=get_enum_type(FrontDoorRedirectType), help='The redirect type the rule will use when redirecting traffic.')
        c.argument('redirect_protocol', arg_type=get_enum_type(FrontDoorRedirectProtocol), help='The protocol of the destination to where the traffic is redirected.')
        c.argument('custom_host', help='Host to redirect. Leave empty to use use the incoming host as the destination host.')
        c.argument('custom_path', help='The full path to redirect. Path cannot be empty and must start with /. Leave empty to use the incoming path as destination path.')
        c.argument('custom_fragment', help='Fragment to add to the redirect URL. Fragment is the part of the URL that comes after #. Do not include the #.')
        c.argument('custom_query_string', help='The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the incoming query string. Query string must be in <key>=<value> format. The first ? and & will be added automatically so do not include them in the front, but do separate multiple query strings with &.')
    # endregion

    # region WafPolicy
    with self.argument_context('network front-door waf-policy') as c:
        c.argument('tags', tags_type)
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create in a disabled state.')
        c.argument('enabled', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Enabled status.')
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('mode', arg_type=get_enum_type(PolicyMode), help='Firewall policy mode.')
        c.argument('policy_name', waf_policy_name_type, options_list=['--name', '-n'])
        c.argument('redirect_url', help='URL used for redirect rule action.')
        c.argument('custom_block_response_status_code', help='HTTP status to return for blocked requests.')
        c.argument('custom_block_response_body', help='Body to return for blocked requests.')

    with self.argument_context('network front-door waf-policy managed-rules add') as c:
        c.argument('policy_name', waf_policy_name_type)
        c.argument('action', arg_type=get_enum_type(ActionType), help='Action for applied rulesets.')
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset to apply.')
        c.argument('version', help='Rule set version.')

    with self.argument_context('network front-door waf-policy managed-rules list') as c:
        c.argument('policy_name', waf_policy_name_type, id_part=None)

    with self.argument_context('network front-door waf-policy managed-rules override add') as c:
        c.argument('policy_name', waf_policy_name_type)
        c.argument('action', arg_type=get_enum_type(ActionType), help='Action for applied rulesets.')
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset to override.')
        c.argument('rule_group_id', help='ID of the rule group containing the rule to override.')
        c.argument('rule_id', help='ID of the rule to override.')
        c.argument('disabled', help='Whether to disable the rule.')

    with self.argument_context('network front-door waf-policy managed-rules override remove') as c:
        c.argument('policy_name', waf_policy_name_type)
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset with the override to remove.')
        c.argument('rule_group_id', help='ID of the rule group containing the override to remove.')
        c.argument('rule_id', help='ID of the rule override to remove.')

    with self.argument_context('network front-door waf-policy managed-rules override list') as c:
        c.argument('policy_name', waf_policy_name_type, id_part=None)
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset with the overrides to list.')

    with self.argument_context('network front-door waf-policy managed-rules exclusion add') as c:
        c.argument('policy_name', waf_policy_name_type)
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset to exclusion.')
        c.argument('rule_group_id', help='ID of the rule group containing the rule to exclusion.')
        c.argument('rule_id', help='ID of the rule to apply exclusion.')
        c.argument('match_variable', help='Which kind of variable\'s content will be ignored, e.g. RequestHeaderNames, RequestCookieNames, QueryStringArgNames, RequestBodyPostArgNames.')
        c.argument('operator', help='Operator used to compare the variable name to the value, e.g. Equals, Contains, StartsWith, EndsWith, EqualsAny.')
        c.argument('value', help='Values to match the variable name against.')

    with self.argument_context('network front-door waf-policy managed-rules exclusion remove') as c:
        c.argument('policy_name', waf_policy_name_type)
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset with the exclusion to remove.')
        c.argument('rule_group_id', help='ID of the rule group containing the exclusion to remove.')
        c.argument('rule_id', help='ID of the rule to remove from exclusion.')
        c.argument('match_variable', help='Which kind of variable\'s content will be ignored, e.g. RequestHeaderNames, RequestCookieNames, QueryStringArgNames, RequestBodyPostArgNames.')
        c.argument('operator', help='Operator used to compare the variable name to the value, e.g. Equals, Contains, StartsWith, EndsWith, EqualsAny.')
        c.argument('value', help='Values to match the variable name against.')

    with self.argument_context('network front-door waf-policy managed-rules exclusion list') as c:
        c.argument('policy_name', waf_policy_name_type, id_part=None)
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset with the exclusions to list.')
        c.argument('rule_group_id', help='ID of the rule group containing the exclusions to list.')
        c.argument('rule_id', help='ID of the rule to list exclusion for.')

    with self.argument_context('network front-door waf-policy managed-rules remove') as c:
        c.argument('policy_name', waf_policy_name_type)
        c.argument('rule_set_type', options_list=['--type'], help='ID of the ruleset to remove.')

    with self.argument_context('network front-door waf-policy managed-rule-definition list') as c:
        c.argument('policy_name', waf_policy_name_type)

    with self.argument_context('network front-door waf-policy rule create') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)
        c.argument('priority', type=int, help='Priority of the rule.')
        c.argument('rate_limit_duration', type=int, help='Rate limit duration in minutes.')
        c.argument('rate_limit_threshold', type=int, help='Rate limit threshold.')
        c.argument('rule_type', arg_type=get_enum_type(RuleType), help='Type of rule.')
        c.argument('action', arg_type=get_enum_type(ActionType), help='Rule action.')
        c.argument('disabled', help='Whether to disable the rule.')

    with self.argument_context('network front-door waf-policy rule delete') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)

    with self.argument_context('network front-door waf-policy rule show') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)

    with self.argument_context('network front-door waf-policy rule update') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)
        c.argument('priority', type=int, help='Priority of the rule.')
        c.argument('rate_limit_duration', type=int, help='Rate limit duration in minutes.')
        c.argument('rate_limit_threshold', type=int, help='Rate limit threshold.')
        c.argument('rule_type', arg_type=get_enum_type(RuleType), help='Type of rule.')
        c.argument('action', arg_type=get_enum_type(ActionType), help='Rule action.')
        c.argument('disabled', help='Whether to disable the rule.')

    with self.argument_context('network front-door waf-policy rule list') as c:
        c.argument('policy_name', waf_policy_name_type, id_part=None)

    with self.argument_context('network front-door waf-policy rule match-condition add') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)
        c.argument('match_variable', help='Variable[.Selector] Request variable to test with optional selector.')
        c.argument('operator', help='Operator used to compare the variable to the values.')
        c.argument('values', nargs='+', help='Space-separated list of values to match against.')
        c.argument('negate', arg_type=get_three_state_flag(), help='Applies "Not" to the operator.')
        c.argument('transforms', nargs='+', arg_type=get_enum_type(TransformType), help='Space-separated list of transforms to apply.')

    with self.argument_context('network front-door waf-policy rule match-condition remove') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.', id_part='child_name_1')
        c.argument('policy_name', waf_policy_name_type)
        c.argument('index', type=int, help='0-based index of the match condition to remove')

    with self.argument_context('network front-door waf-policy rule match-condition list') as c:
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the custom rule.')
        c.argument('policy_name', waf_policy_name_type, id_part=None)
    # endregion

    # region RulesEngine
    with self.argument_context('network front-door rules-engine') as c:
        c.argument('front_door_name', frontdoor_name_type, id_part=None)
        c.argument('rules_engine_name', rules_engine_name_type, options_list=['--name', '-n'], id_part=None)

    with self.argument_context('network front-door rules-engine rule') as c:
        c.argument('front_door_name', frontdoor_name_type, id_part=None)
        c.argument('rules_engine_name', rules_engine_name_type, id_part=None)
        c.argument('rule_name', options_list=['--name', '-n'], help='Name of the rule')
        c.argument('action_type', arg_group="Action", arg_type=get_enum_type(['RequestHeader', 'ResponseHeader']), help='Action type to apply for a rule.')
        c.argument('header_action', arg_group="Action", arg_type=get_enum_type(HeaderActionType), help='Header action type for the requests.')
        c.argument('header_name', arg_group="Action", help='Name of the header to modify.')
        c.argument('header_value', arg_group="Action", help='Value of the header.')
        c.argument('match_variable', arg_group="Match Condition", arg_type=get_enum_type(RulesEngineMatchVariable), help='Name of the match condition.')
        c.argument('operator', arg_group="Match Condition", arg_type=get_enum_type(RulesEngineOperator), help='Operator of the match condition.')
        c.argument('match_values', arg_group="Match Condition", nargs='+', help='Space-separated list of values to match against.')
        c.argument('selector', arg_group="Match Condition", help='Optional selector for the match condition variable.')
        c.argument('negate_condition', arg_group="Match Condition", arg_type=get_three_state_flag(), help='Applies "Not" to the operator.')
        c.argument('transforms', arg_group="Match Condition", nargs='+', arg_type=get_enum_type(Transform), help='Space-separated list of transforms to apply.')
        c.argument('priority', help='The priority number must start from 0 and consecutive. Rule with greater priority value will be applied later.')
        c.argument('match_processing_behavior', arg_type=get_enum_type(MatchProcessingBehavior), help='Whether to stop processing rules after conditions in a rule is satisfied.')

    with self.argument_context('network front-door rules-engine rule action', arg_group='Forward Route Override') as c:
        c.argument('action_type', arg_group="Action", arg_type=get_enum_type(['RequestHeader', 'ResponseHeader', 'ForwardRouteOverride', 'RedirectRouteOverride']), help='Action type to apply for a rule.')
        c.argument('backend_pool', help='Name or ID of a backend pool.', validator=validate_backend_pool)
        c.argument('forwarding_protocol', arg_type=get_enum_type(FrontDoorForwardingProtocol), help='Protocol to use for forwarding traffic.')
        c.argument('custom_forwarding_path', help='Custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path.')
        c.argument('caching', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=False), help='Whether to enable caching for this route.')
        c.argument('cache_duration', help='The duration for which the content needs to be cached. Allowed format is ISO 8601 duration')
        c.argument('dynamic_compression', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Use dynamic compression for cached content.')
        c.argument('query_parameter_strip_directive', arg_type=get_enum_type(FrontDoorQuery), help='Treatment of URL query terms when forming the cache key.')
        c.argument('query_parameters', help='Query parameters to include or exclude (comma separated) when using query-parameter-strip-directive type StripAllExcept or StripOnly respectively.')

    with self.argument_context('network front-door rules-engine rule action', arg_group='Redirect Route Override') as c:
        c.argument('redirect_type', arg_type=get_enum_type(FrontDoorRedirectType), help='The redirect type the rule will use when redirecting traffic.')
        c.argument('redirect_protocol', arg_type=get_enum_type(FrontDoorRedirectProtocol), help='The protocol of the destination to where the traffic is redirected.')
        c.argument('custom_host', help='Host to redirect. Leave empty to use use the incoming host as the destination host.')
        c.argument('custom_path', help='The full path to redirect. Path cannot be empty and must start with /. Leave empty to use the incoming path as destination path.')
        c.argument('custom_fragment', help='Fragment to add to the redirect URL. Fragment is the part of the URL that comes after #. Do not include the #.')
        c.argument('custom_query_string', help='The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the incoming query string. Query string must be in <key>=<value> format. The first ? and & will be added automatically so do not include them in the front, but do separate multiple query strings with &.')

    with self.argument_context('network front-door rules-engine rule condition remove') as c:
        c.argument('index', type=int, help='0-based index of the match condition to remove')

    with self.argument_context('network front-door rules-engine rule action remove') as c:
        c.argument('index', type=int, help='0-based index of the request or response header action to remove. Index parameter is not required for "ForwardRouteOverride" or "RedirectRouteOverride" action remove')

    with self.argument_context('network front-door rules-engine rule list') as c:
        c.argument('front_door_name', frontdoor_name_type, id_part=None)
        c.argument('rules_engine_name', rules_engine_name_type, options_list=['--name', '-n'], id_part=None)
示例#32
0
def load_arguments(self, _):
    StorageAccountTypes, UpgradeMode, CachingTypes = self.get_models('StorageAccountTypes', 'UpgradeMode', 'CachingTypes')
    OperatingSystemTypes = self.get_models('OperatingSystemTypes')

    # REUSABLE ARGUMENT DEFINITIONS
    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    multi_ids_type = CLIArgumentType(nargs='+')
    existing_vm_name = CLIArgumentType(overrides=name_arg_type,
                                       configured_default='vm',
                                       help="The name of the Virtual Machine. You can configure the default using `az configure --defaults vm=<name>`",
                                       completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines'), id_part='name')
    existing_disk_name = CLIArgumentType(overrides=name_arg_type, help='The name of the managed disk', completer=get_resource_name_completion_list('Microsoft.Compute/disks'), id_part='name')
    existing_snapshot_name = CLIArgumentType(overrides=name_arg_type, help='The name of the snapshot', completer=get_resource_name_completion_list('Microsoft.Compute/snapshots'), id_part='name')
    vmss_name_type = CLIArgumentType(name_arg_type,
                                     configured_default='vmss',
                                     completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'),
                                     help="Scale set name. You can configure the default using `az configure --defaults vmss=<name>`",
                                     id_part='name')

    extension_instance_name_type = CLIArgumentType(help="Name of the vm's instance of the extension. Default: name of the extension.")

    if StorageAccountTypes:
        disk_sku = CLIArgumentType(arg_type=get_enum_type(StorageAccountTypes))
    else:
        # StorageAccountTypes introduced in api version 2016_04_30_preview of Resource.MGMT.Compute package..
        # However, 2017-03-09-profile targets version 2016-03-30 of compute package.
        disk_sku = CLIArgumentType(arg_type=get_enum_type(['Premium_LRS', 'Standard_LRS']))

    # special case for `network nic scale-set list` command alias
    with self.argument_context('network nic scale-set list') as c:
        c.argument('virtual_machine_scale_set_name', options_list=['--vmss-name'], completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'), id_part='name')

    # region MixedScopes
    for scope in ['vm', 'disk', 'snapshot', 'image', 'sig']:
        with self.argument_context(scope) as c:
            c.argument('tags', tags_type)

    for scope in ['disk', 'snapshot']:
        with self.argument_context(scope) as c:
            c.ignore('source_blob_uri', 'source_disk', 'source_snapshot')
            c.argument('source_storage_account_id', help='used when source blob is in a different subscription')
            c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB. Max size: 4095 GB (certain preview disks can be larger).', type=int)
            c.argument('duration_in_seconds', help='Time duration in seconds until the SAS access expires', type=int)

    for scope in ['disk create', 'snapshot create']:
        with self.argument_context(scope) as c:
            c.argument('source', help='source to create the disk/snapshot from, including unmanaged blob uri, managed disk id or name, or snapshot id or name')
    # endregion

    # region Disks
    with self.argument_context('disk') as c:
        c.argument('zone', zone_type, min_api='2017-03-30', options_list=['--zone'])  # TODO: --size-gb currently has claimed -z. We can do a breaking change later if we want to.
        c.argument('disk_name', existing_disk_name, completer=get_resource_name_completion_list('Microsoft.Compute/disks'))
        c.argument('name', arg_type=name_arg_type)
        c.argument('sku', arg_type=disk_sku, help='Underlying storage SKU')
        c.argument('os_type', arg_type=get_enum_type(OperatingSystemTypes), help='The Operating System type of the Disk.')
        c.argument('disk_iops_read_write', type=int, min_api='2018-06-01', help='The number of IOPS allowed for this disk. Only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes')
        c.argument('disk_mbps_read_write', type=int, min_api='2018-06-01', help="The bandwidth allowed for this disk. Only settable for UltraSSD disks. MBps means millions of bytes per second with ISO notation of powers of 10")
    # endregion

    # region Snapshots
    with self.argument_context('snapshot', resource_type=ResourceType.MGMT_COMPUTE, operation_group='snapshots') as c:
        c.argument('snapshot_name', existing_snapshot_name, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/snapshots'))
        c.argument('name', arg_type=name_arg_type)
        if self.supported_api_version(min_api='2018-04-01', operation_group='snapshots'):
            c.argument('sku', arg_type=get_enum_type(['Premium_LRS', 'Standard_LRS', 'Standard_ZRS']))
        else:
            c.argument('sku', arg_type=get_enum_type(['Premium_LRS', 'Standard_LRS']))
    # endregion

    # region Images
    with self.argument_context('image') as c:
        c.argument('os_type', arg_type=get_enum_type(['Windows', 'Linux']))
        c.argument('image_name', arg_type=name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/images'))

    with self.argument_context('image create') as c:
        # here we collpase all difference image sources to under 2 common arguments --os-disk-source --data-disk-sources
        c.argument('name', arg_type=name_arg_type, help='new image name')
        c.argument('source', help='OS disk source from the same region, including a virtual machine ID or name, OS disk blob URI, managed OS disk ID or name, or OS snapshot ID or name')
        c.argument('data_disk_sources', nargs='+', help='Space-separated list of data disk sources, including unmanaged blob URI, managed disk ID or name, or snapshot ID or name')
        c.argument('zone_resilient', min_api='2017-12-01', arg_type=get_three_state_flag(), help='Specifies whether an image is zone resilient or not. '
                   'Default is false. Zone resilient images can be created only in regions that provide Zone Redundant Storage')
        c.argument('storage_sku', arg_type=disk_sku, help='The SKU of the storage account with which to create the VM image. Unused if source VM is specified.')
        c.argument('os_disk_caching', arg_type=get_enum_type(CachingTypes), help="Storage caching type for the image's OS disk.")
        c.ignore('source_virtual_machine', 'os_blob_uri', 'os_disk', 'os_snapshot', 'data_blob_uris', 'data_disks', 'data_snapshots')
    # endregion

    # region AvailabilitySets
    with self.argument_context('vm availability-set') as c:
        c.argument('availability_set_name', name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')

    with self.argument_context('vm availability-set create') as c:
        c.argument('availability_set_name', name_arg_type, validator=get_default_location_from_resource_group, help='Name of the availability set')
        c.argument('platform_update_domain_count', type=int, help='Update Domain count. If unspecified, the server will pick the most optimal number like 5.')
        c.argument('platform_fault_domain_count', type=int, help='Fault Domain count.')
        c.argument('validate', help='Generate and validate the ARM template without creating any resources.', action='store_true')
        c.argument('unmanaged', action='store_true', min_api='2016-04-30-preview', help='contained VMs should use unmanaged disks')

    with self.argument_context('vm availability-set update') as c:
        if self.supported_api_version(max_api='2016-04-30-preview', operation_group='virtual_machines'):
            c.argument('name', name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')
            c.argument('availability_set_name', options_list=['--availability-set-name'])
    # endregion

    # region VirtualMachines
    with self.argument_context('vm') as c:
        c.argument('vm_name', existing_vm_name)
        c.argument('size', completer=get_vm_size_completion_list)
        c.argument('name', arg_type=name_arg_type)
        c.argument('zone', zone_type, min_api='2017-03-30')
        c.argument('caching', help='Disk caching policy', arg_type=get_enum_type(CachingTypes))
        c.argument('nsg', help='The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none.', arg_group='Network')
        c.argument('nsg_rule', help='NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux.', arg_group='Network', arg_type=get_enum_type(['RDP', 'SSH']))
        c.argument('application_security_groups', min_api='2017-09-01', nargs='+', options_list=['--asgs'], help='Space-separated list of existing application security groups to associate with the VM.', arg_group='Network')

    with self.argument_context('vm capture') as c:
        c.argument('overwrite', action='store_true')

    with self.argument_context('vm update') as c:
        c.argument('os_disk', min_api='2017-12-01', help="Managed OS disk ID or name to swap to")
        c.argument('write_accelerator', nargs='*', min_api='2017-12-01',
                   help="enable/disable disk write accelerator. Use singular value 'true/false' to apply across, or specify individual disks, e.g.'os=true 1=true 2=true' for os disk and data disks with lun of 1 & 2")
        c.argument('disk_caching', nargs='*', help="Use singular value to apply across, or specify individual disks, e.g. 'os=ReadWrite 0=None 1=ReadOnly' should enable update os disk and 2 data disks")

    with self.argument_context('vm create') as c:
        c.argument('name', name_arg_type, validator=_resource_not_exists(self.cli_ctx, 'Microsoft.Compute/virtualMachines'))
        c.argument('vm_name', name_arg_type, id_part=None, help='Name of the virtual machine.', completer=None)
        c.argument('os_disk_size_gb', type=int, help='the size of the os disk in GB', arg_group='Storage')
        c.argument('attach_os_disk', help='Attach an existing OS disk to the VM. Can use the name or ID of a managed disk or the URI to an unmanaged disk VHD.')
        c.argument('attach_data_disks', nargs='+', help='Attach existing data disks to the VM. Can use the name or ID of a managed disk or the URI to an unmanaged disk VHD.')
        c.argument('availability_set', help='Name or ID of an existing availability set to add the VM to. None by default.')
        c.argument('nsg', help='The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none.', arg_group='Network')
        c.argument('nsg_rule', help='NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux.', arg_group='Network', arg_type=get_enum_type(['RDP', 'SSH']))
        c.argument('application_security_groups', resource_type=ResourceType.MGMT_NETWORK, min_api='2017-09-01', nargs='+', options_list=['--asgs'], help='Space-separated list of existing application security groups to associate with the VM.', arg_group='Network', validator=validate_asg_names_or_ids)
        c.argument('boot_diagnostics_storage',
                   help='pre-existing storage account name or its blob uri to capture boot diagnostics. Its sku should be one of Standard_GRS, Standard_LRS and Standard_RAGRS')
        c.argument('accelerated_networking', resource_type=ResourceType.MGMT_NETWORK, min_api='2016-09-01', arg_type=get_three_state_flag(), arg_group='Network',
                   help="enable accelerated networking. Unless specified, CLI will enable it based on machine image and size")

    with self.argument_context('vm open-port') as c:
        c.argument('vm_name', name_arg_type, help='The name of the virtual machine to open inbound traffic on.')
        c.argument('network_security_group_name', options_list=('--nsg-name',), help='The name of the network security group to create if one does not exist. Ignored if an NSG already exists.', validator=validate_nsg_name)
        c.argument('apply_to_subnet', help='Allow inbound traffic on the subnet instead of the NIC', action='store_true')
        c.argument('port', help="The port or port range (ex: 80-100) to open inbound traffic to. Use '*' to allow traffic to all ports.")
        c.argument('priority', help='Rule priority, between 100 (highest priority) and 4096 (lowest priority). Must be unique for each rule in the collection.', type=int)

    for scope in ['vm show', 'vm list']:
        with self.argument_context(scope) as c:
            c.argument('show_details', action='store_true', options_list=['--show-details', '-d'], help='show public ip address, FQDN, and power states. command will run slow')

    with self.argument_context('vm diagnostics') as c:
        c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'])

    with self.argument_context('vm diagnostics set') as c:
        c.argument('storage_account', completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'))

    with self.argument_context('vm disk') as c:
        c.argument('vm_name', options_list=['--vm-name'], id_part=None, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines'))
        c.argument('new', action='store_true', help='create a new disk')
        c.argument('sku', arg_type=disk_sku, help='Underlying storage SKU')
        c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB. Max size: 4095 GB (certain preview disks can be larger).', type=int)
        c.argument('lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virtual Machine size.')

    with self.argument_context('vm disk attach') as c:
        c.argument('enable_write_accelerator', min_api='2017-12-01', action='store_true', help='enable write accelerator')
        c.argument('disk', options_list=['--name', '-n', c.deprecate(target='--disk', redirect='--name', hide=True)],
                   help="The name or ID of the managed disk", validator=validate_vm_disk, id_part='name',
                   completer=get_resource_name_completion_list('Microsoft.Compute/disks'))

    with self.argument_context('vm disk detach') as c:
        c.argument('disk_name', arg_type=name_arg_type, help='The data disk name.')

    with self.argument_context('vm encryption enable') as c:
        c.argument('encrypt_format_all', action='store_true', help='Encrypts-formats data disks instead of encrypting them. Encrypt-formatting is a lot faster than in-place encryption but wipes out the partition getting encrypt-formatted.')

    with self.argument_context('vm extension') as c:
        c.argument('vm_extension_name', name_arg_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines/extensions'), help='Name of the extension.', id_part='child_name_1')
        c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'], id_part='name')
        c.argument('expand', deprecate_info=c.deprecate(expiration='2.1.0', hide=True))

    with self.argument_context('vm extension list') as c:
        c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'], id_part=None)

    with self.argument_context('vm secret') as c:
        c.argument('secrets', multi_ids_type, options_list=['--secrets', '-s'], help='Space-separated list of key vault secret URIs. Perhaps, produced by \'az keyvault secret list-versions --vault-name vaultname -n cert1 --query "[?attributes.enabled].id" -o tsv\'')
        c.argument('keyvault', help='Name or ID of the key vault.', validator=validate_keyvault)
        c.argument('certificate', help='key vault certificate name or its full secret URL')
        c.argument('certificate_store', help='Windows certificate store names. Default: My')

    with self.argument_context('vm secret list') as c:
        c.argument('vm_name', arg_type=existing_vm_name, id_part=None)

    with self.argument_context('vm image') as c:
        c.argument('publisher_name', options_list=['--publisher', '-p'])
        c.argument('publisher', options_list=['--publisher', '-p'], help='image publisher')
        c.argument('offer', options_list=['--offer', '-f'], help='image offer')
        c.argument('plan', help='image billing plan')
        c.argument('sku', options_list=['--sku', '-s'], help='image sku')
        c.argument('version', help="image sku's version")
        c.argument('urn', help="URN, in format of 'publisher:offer:sku:version'. If specified, other argument values can be omitted")

    with self.argument_context('vm image list') as c:
        c.argument('image_location', get_location_type(self.cli_ctx))

    with self.argument_context('vm image show') as c:
        c.argument('skus', options_list=['--sku', '-s'])

    with self.argument_context('vm nic') as c:
        c.argument('vm_name', existing_vm_name, options_list=['--vm-name'], id_part=None)
        c.argument('nics', nargs='+', help='Names or IDs of NICs.', validator=validate_vm_nics)
        c.argument('primary_nic', help='Name or ID of the primary NIC. If missing, the first NIC in the list will be the primary.')

    with self.argument_context('vm nic show') as c:
        c.argument('nic', help='NIC name or ID.', validator=validate_vm_nic)

    with self.argument_context('vm unmanaged-disk') as c:
        c.argument('new', action='store_true', help='Create a new disk.')
        c.argument('lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virtual Machine size.')
        c.argument('vhd_uri', help="Virtual hard disk URI. For example: https://mystorage.blob.core.windows.net/vhds/d1.vhd")

    with self.argument_context('vm unmanaged-disk attach') as c:
        c.argument('disk_name', options_list=['--name', '-n'], help='The data disk name.')
        c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB. Max size: 4095 GB (certain preview disks can be larger).', type=int)

    with self.argument_context('vm unmanaged-disk detach') as c:
        c.argument('disk_name', options_list=['--name', '-n'], help='The data disk name.')

    for scope in ['vm unmanaged-disk attach', 'vm unmanaged-disk detach']:
        with self.argument_context(scope) as c:
            c.argument('vm_name', arg_type=existing_vm_name, options_list=['--vm-name'], id_part=None)

    with self.argument_context('vm unmanaged-disk list') as c:
        c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], arg_type=existing_vm_name, id_part=None)

    with self.argument_context('vm user') as c:
        c.argument('username', options_list=['--username', '-u'], help='The user name')
        c.argument('password', options_list=['--password', '-p'], help='The user password')

    with self.argument_context('vm list-skus') as c:
        c.argument('size', options_list=['--size', '-s'], help="size name, partial name is accepted")
        c.argument('zone', options_list=['--zone', '-z'], arg_type=get_three_state_flag(), help="show all vm size supporting availability zones")
        c.argument('show_all', options_list=['--all'], arg_type=get_three_state_flag(),
                   help="show all information including vm sizes not available under the current subscription")
        c.argument('resource_type', options_list=['--resource-type', '-r'], help='resource types e.g. "availabilitySets", "snapshots", "disk", etc')

    with self.argument_context('vm restart') as c:
        c.argument('force', action='store_true', help='Force the VM to restart by redeploying it. Use if the VM is unresponsive.')
    # endregion

    # region VMSS
    scaleset_name_aliases = ['vm_scale_set_name', 'virtual_machine_scale_set_name', 'name']

    with self.argument_context('vmss') as c:
        c.argument('zones', zones_type, min_api='2017-03-30')
        c.argument('instance_id', id_part='child_name_1')
        c.argument('instance_ids', multi_ids_type, help='Space-separated list of IDs (ex: 1 2 3 ...) or * for all instances. If not provided, the action will be applied on the scaleset itself')
        c.argument('tags', tags_type)
        c.argument('caching', help='Disk caching policy', arg_type=get_enum_type(CachingTypes))
        for dest in scaleset_name_aliases:
            c.argument(dest, vmss_name_type)

    for scope in ['vmss deallocate', 'vmss delete-instances', 'vmss restart', 'vmss start', 'vmss stop', 'vmss show', 'vmss update-instances']:
        with self.argument_context(scope) as c:
            for dest in scaleset_name_aliases:
                c.argument(dest, vmss_name_type, id_part=None)  # due to instance-ids parameter

    with self.argument_context('vmss create') as c:
        VMPriorityTypes = self.get_models('VirtualMachinePriorityTypes', resource_type=ResourceType.MGMT_COMPUTE)
        VirtualMachineEvictionPolicyTypes = self.get_models('VirtualMachineEvictionPolicyTypes', resource_type=ResourceType.MGMT_COMPUTE)
        c.argument('name', name_arg_type)
        c.argument('nat_backend_port', default=None, help='Backend port to open with NAT rules.  Defaults to 22 on Linux and 3389 on Windows.')
        c.argument('single_placement_group', arg_type=get_three_state_flag(), help="Enable replicate using fault domains within the same cluster. Default to 'false' for any zonals, or with 100+ instances"
                   " See https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-placement-groups for details")
        c.argument('platform_fault_domain_count', type=int, help='Fault Domain count for each placement group in the availability zone', min_api='2017-12-01')
        c.argument('vmss_name', name_arg_type, id_part=None, help='Name of the virtual machine scale set.')
        c.argument('instance_count', help='Number of VMs in the scale set.', type=int)
        c.argument('disable_overprovision', help='Overprovision option (see https://azure.microsoft.com/en-us/documentation/articles/virtual-machine-scale-sets-overview/ for details).', action='store_true')
        c.argument('upgrade_policy_mode', help=None, arg_type=get_enum_type(UpgradeMode))
        c.argument('health_probe', help='(Preview) probe name from the existing load balancer, mainly used for rolling upgrade')
        c.argument('vm_sku', help='Size of VMs in the scale set. Default to "Standard_DS1_v2". See https://azure.microsoft.com/en-us/pricing/details/virtual-machines/ for size info.')
        c.argument('nsg', help='Name or ID of an existing Network Security Group.', arg_group='Network')
        c.argument('priority', resource_type=ResourceType.MGMT_COMPUTE, min_api='2017-12-01', arg_type=get_enum_type(VMPriorityTypes, default=None),
                   help="Priority. Use 'Low' to run short-lived workloads in a cost-effective way")
        c.argument('eviction_policy', resource_type=ResourceType.MGMT_COMPUTE, min_api='2017-12-01', arg_type=get_enum_type(VirtualMachineEvictionPolicyTypes, default=None),
                   help="(PREVIEW) The eviction policy for virtual machines in a low priority scale set.")
        c.argument('application_security_groups', resource_type=ResourceType.MGMT_COMPUTE, min_api='2018-06-01', nargs='+', options_list=['--asgs'], help='Space-separated list of existing application security groups to associate with the VM.', arg_group='Network', validator=validate_asg_names_or_ids)

    with self.argument_context('vmss create', arg_group='Network Balancer') as c:
        LoadBalancerSkuName = self.get_models('LoadBalancerSkuName', resource_type=ResourceType.MGMT_NETWORK)
        c.argument('application_gateway', help='Name to use when creating a new application gateway (default) or referencing an existing one. Can also reference an existing application gateway by ID or specify "" for none.', options_list=['--app-gateway'])
        c.argument('app_gateway_capacity', help='The number of instances to use when creating a new application gateway.')
        c.argument('app_gateway_sku', help='SKU when creating a new application gateway.')
        c.argument('app_gateway_subnet_address_prefix', help='The subnet IP address prefix to use when creating a new application gateway in CIDR format.')
        c.argument('backend_pool_name', help='Name to use for the backend pool when creating a new load balancer or application gateway.')
        c.argument('backend_port', help='When creating a new load balancer, backend port to open with NAT rules (Defaults to 22 on Linux and 3389 on Windows). When creating an application gateway, the backend port to use for the backend HTTP settings.', type=int)
        c.argument('load_balancer', help='Name to use when creating a new load balancer (default) or referencing an existing one. Can also reference an existing load balancer by ID or specify "" for none.', options_list=['--load-balancer', '--lb'])
        c.argument('load_balancer_sku', resource_type=ResourceType.MGMT_NETWORK, min_api='2017-08-01', options_list=['--lb-sku'], arg_type=get_enum_type(LoadBalancerSkuName),
                   help="Sku of the Load Balancer to create. Default to 'Standard' when single placement group is turned off; otherwise, default to 'Basic'")
        c.argument('nat_pool_name', help='Name to use for the NAT pool when creating a new load balancer.', options_list=['--lb-nat-pool-name', '--nat-pool-name'])

    with self.argument_context('vmss create', min_api='2017-03-30', arg_group='Network') as c:
        c.argument('public_ip_per_vm', action='store_true', help="Each VM instance will have a public ip. For security, you can use '--nsg' to apply appropriate rules")
        c.argument('vm_domain_name', help="domain name of VM instances, once configured, the FQDN is 'vm<vm-index>.<vm-domain-name>.<..rest..>'")
        c.argument('dns_servers', nargs='+', help="space-separated IP addresses of DNS servers, e.g. 10.0.0.5 10.0.0.6")
        c.argument('accelerated_networking', arg_type=get_three_state_flag(),
                   help="enable accelerated networking. Unless specified, CLI will enable it based on machine image and size")

    for scope in ['vmss update-instances', 'vmss delete-instances']:
        with self.argument_context(scope) as c:
            c.argument('instance_ids', multi_ids_type, help='Space-separated list of IDs (ex: 1 2 3 ...) or * for all instances.')

    with self.argument_context('vmss diagnostics') as c:
        c.argument('vmss_name', id_part=None, help='Scale set name')

    with self.argument_context('vmss disk') as c:
        options_list = ['--vmss-name'] + [c.deprecate(target=opt, redirect='--vmss-name', hide=True)for opt in name_arg_type.settings['options_list']]
        new_vmss_name_type = CLIArgumentType(overrides=vmss_name_type, options_list=options_list)

        c.argument('lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virtual Machine instance size.')
        c.argument('size_gb', options_list=['--size-gb', '-z'], help='size in GB. Max size: 4095 GB (certain preview disks can be larger).', type=int)
        c.argument('vmss_name', new_vmss_name_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'))
        c.argument('disk', validator=validate_vmss_disk, help='existing disk name or ID to attach or detach from VM instances',
                   min_api='2017-12-01', completer=get_resource_name_completion_list('Microsoft.Compute/disks'))
        c.argument('instance_id', help='Scale set VM instance id', min_api='2017-12-01')
        c.argument('sku', arg_type=disk_sku, help='Underlying storage SKU')

    with self.argument_context('vmss encryption') as c:
        c.argument('vmss_name', vmss_name_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'))

    with self.argument_context('vmss extension') as c:
        c.argument('extension_name', name_arg_type, help='Name of the extension.')
        c.argument('vmss_name', vmss_name_type, options_list=['--vmss-name'], id_part=None)

    with self.argument_context('vmss nic') as c:
        c.argument('virtual_machine_scale_set_name', options_list=['--vmss-name'], help='Scale set name.', completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'), id_part='name')
        c.argument('virtualmachine_index', options_list=['--instance-id'], id_part='child_name_1')
        c.argument('network_interface_name', options_list=['--name', '-n'], metavar='NIC_NAME', help='The network interface (NIC).', completer=get_resource_name_completion_list('Microsoft.Network/networkInterfaces'), id_part='child_name_2')

    with self.argument_context('vmss nic list') as c:
        c.argument('virtual_machine_scale_set_name', arg_type=vmss_name_type, options_list=['--vmss-name'], id_part=None)
    # endregion

    # region VM & VMSS Shared
    for scope in ['vm', 'vmss']:
        with self.argument_context(scope) as c:
            c.argument('no_auto_upgrade', arg_type=get_three_state_flag(), help='If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.')

        with self.argument_context('{} run-command'.format(scope)) as c:
            c.argument('command_id', completer=get_vm_run_command_completion_list, help="The command id. Use 'az {} run-command list' to get the list".format(scope))
            if scope == 'vmss':
                c.argument('vmss_name', vmss_name_type)

        with self.argument_context('{} run-command invoke'.format(scope)) as c:
            c.argument('parameters', nargs='+', help="space-separated parameters in the format of '[name=]value'")
            c.argument('scripts', nargs='+', help="script lines separated by whites spaces. Use @{file} to load from a file")

    for scope in ['vm identity assign', 'vmss identity assign']:
        with self.argument_context(scope) as c:
            c.argument('assign_identity', options_list=['--identities'], nargs='*', help="Space-separated identities to assign. Use '{0}' to refer to the system assigned identity. Default: '{0}'".format(MSI_LOCAL_ID))
            c.argument('vm_name', existing_vm_name)
            c.argument('vmss_name', vmss_name_type)

    for scope in ['vm identity remove', 'vmss identity remove']:
        with self.argument_context(scope) as c:
            c.argument('identities', nargs='+', help="Space-separated identities to remove. Use '{0}' to refer to the system assigned identity. Default: '{0}'".format(MSI_LOCAL_ID))
            c.argument('vm_name', existing_vm_name)
            c.argument('vmss_name', vmss_name_type)

    for scope in ['vm identity show', 'vmss identity show']:
        with self.argument_context(scope) as c:
            c.argument('vm_name', existing_vm_name)
            c.argument('vmss_name', vmss_name_type)

    for scope in ['vm create', 'vmss create']:
        with self.argument_context(scope) as c:
            c.argument('location', get_location_type(self.cli_ctx), help='Location in which to create VM and related resources. If default location is not configured, will default to the resource group\'s location')
            c.argument('tags', tags_type)
            c.argument('no_wait', help='Do not wait for the long-running operation to finish.')
            c.argument('validate', options_list=['--validate'], help='Generate and validate the ARM template without creating any resources.', action='store_true')
            c.argument('size', help='The VM size to be created. See https://azure.microsoft.com/en-us/pricing/details/virtual-machines/ for size info.')
            c.argument('image', completer=get_urn_aliases_completion_list)
            c.argument('custom_data', help='Custom init script file or text (cloud-init, cloud-config, etc..)', completer=FilesCompleter(), type=file_type)
            c.argument('secrets', multi_ids_type, help='One or many Key Vault secrets as JSON strings or files via `@{path}` containing `[{ "sourceVault": { "id": "value" }, "vaultCertificates": [{ "certificateUrl": "value", "certificateStore": "cert store name (only on windows)"}] }]`', type=file_type, completer=FilesCompleter())
            c.argument('assign_identity', nargs='*', arg_group='Managed Service Identity', help="accept system or user assigned identities separated by spaces. Use '[system]' to refer system assigned identity, or a resource id to refer user assigned identity. Check out help for more examples")
            c.ignore('aux_subscriptions')

        with self.argument_context(scope, arg_group='Authentication') as c:
            c.argument('generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing. The keys will be stored in the ~/.ssh directory')
            c.argument('admin_username', help='Username for the VM.', default=get_default_admin_username())
            c.argument('admin_password', help="Password for the VM if authentication type is 'Password'.")
            c.argument('ssh_key_value', help='SSH public key or public key file path.', completer=FilesCompleter(), type=file_type)
            c.argument('ssh_dest_key_path', help='Destination file path on the VM for the SSH key.')
            c.argument('authentication_type', help='Type of authentication to use with the VM. Defaults to password for Windows and SSH public key for Linux. "all" enables both ssh and password authentication. ', arg_type=get_enum_type(['ssh', 'password', 'all']))

        with self.argument_context(scope, arg_group='Storage') as c:
            if StorageAccountTypes:
                allowed_values = ", ".join([sku.value for sku in StorageAccountTypes])
            else:
                allowed_values = ", ".join(['Premium_LRS', 'Standard_LRS'])

            usage = 'Usage: [--storage-sku SKU | --storage-sku ID=SKU ID=SKU ID=SKU...], where each ID is "os" or a 0-indexed lun.'
            allowed_values = 'Allowed values: {}.'.format(allowed_values)
            storage_sku_help = 'The SKU of the storage account with which to persist VM. Use a singular sku that would be applied across all disks, ' \
                               'or specify individual disks. {} {}'.format(usage, allowed_values)

            c.argument('os_disk_name', help='The name of the new VM OS disk.')
            c.argument('os_type', help='Type of OS installed on a custom VHD. Do not use when specifying an URN or URN alias.', arg_type=get_enum_type(['windows', 'linux']))
            c.argument('storage_account', help="Only applicable when used with `--use-unmanaged-disk`. The name to use when creating a new storage account or referencing an existing one. If omitted, an appropriate storage account in the same resource group and location will be used, or a new one will be created.")
            c.argument('storage_sku', nargs='+', help=storage_sku_help)
            c.argument('storage_container_name', help="Only applicable when used with `--use-unmanaged-disk`. Name of the storage container for the VM OS disk. Default: vhds")
            c.ignore('os_publisher', 'os_offer', 'os_sku', 'os_version', 'storage_profile')
            c.argument('use_unmanaged_disk', action='store_true', help='Do not use managed disk to persist VM')
            c.argument('data_disk_sizes_gb', nargs='+', type=int, help='space-separated empty managed data disk sizes in GB to create')
            c.ignore('disk_info', 'storage_account_type', 'public_ip_address_type', 'nsg_type', 'nic_type', 'vnet_type', 'load_balancer_type', 'app_gateway_type')
            c.argument('os_caching', options_list=[self.deprecate(target='--storage-caching', redirect='--os-disk-caching', hide=True), '--os-disk-caching'], help='Storage caching type for the VM OS disk. Default: ReadWrite', arg_type=get_enum_type(CachingTypes))
            c.argument('data_caching', options_list=['--data-disk-caching'], nargs='+',
                       help="storage caching type for data disk(s), including 'None', 'ReadOnly', 'ReadWrite', etc. Use a singular value to apply on all disks, or use '<lun>=<vaule1> <lun>=<value2>' to configure individual disk")
            c.argument('ultra_ssd_enabled', arg_type=get_three_state_flag(), min_api='2018-06-01',
                       help='(PREVIEW) Enables or disables the capability to have 1 or more managed data disks with UltraSSD_LRS storage account')
            c.argument('ephemeral_os_disk', arg_type=get_three_state_flag(), min_api='2018-06-01',
                       help='(Preview) Allows you to create an OS disk directly on the host node, providing local disk performance and faster VM/VMSS reimage time.')

        with self.argument_context(scope, arg_group='Network') as c:
            c.argument('vnet_name', help='Name of the virtual network when creating a new one or referencing an existing one.')
            c.argument('vnet_address_prefix', help='The IP address prefix to use when creating a new VNet in CIDR format.')
            c.argument('subnet', help='The name of the subnet when creating a new VNet or referencing an existing one. Can also reference an existing subnet by ID. If omitted, an appropriate VNet and subnet will be selected automatically, or a new one will be created.')
            c.argument('subnet_address_prefix', help='The subnet IP address prefix to use when creating a new VNet in CIDR format.')
            c.argument('nics', nargs='+', help='Names or IDs of existing NICs to attach to the VM. The first NIC will be designated as primary. If omitted, a new NIC will be created. If an existing NIC is specified, do not specify subnet, VNet, public IP or NSG.')
            c.argument('private_ip_address', help='Static private IP address (e.g. 10.0.0.5).')
            c.argument('public_ip_address', help='Name of the public IP address when creating one (default) or referencing an existing one. Can also reference an existing public IP by ID or specify "" for None.')
            c.argument('public_ip_address_allocation', help=None, default=None, arg_type=get_enum_type(['dynamic', 'static']))
            c.argument('public_ip_address_dns_name', help='Globally unique DNS name for a newly created public IP.')
            if self.supported_api_version(min_api='2017-08-01', resource_type=ResourceType.MGMT_NETWORK):
                PublicIPAddressSkuName = self.get_models('PublicIPAddressSkuName', resource_type=ResourceType.MGMT_NETWORK)
                c.argument('public_ip_sku', help='Sku', default=None, arg_type=get_enum_type(PublicIPAddressSkuName))

        with self.argument_context(scope, arg_group='Marketplace Image Plan') as c:
            c.argument('plan_name', help='plan name')
            c.argument('plan_product', help='plan product')
            c.argument('plan_publisher', help='plan publisher')
            c.argument('plan_promotion_code', help='plan promotion code')

    for scope in ['vm create', 'vmss create', 'vm identity assign', 'vmss identity assign']:
        with self.argument_context(scope) as c:
            arg_group = 'Managed Service Identity' if scope.split()[-1] == 'create' else None
            c.argument('identity_scope', options_list=['--scope'], arg_group=arg_group, help="Scope that the system assigned identity can access")
            c.argument('identity_role', options_list=['--role'], arg_group=arg_group, help="Role name or id the system assigned identity will have")
            c.ignore('identity_role_id')

    for scope in ['vm diagnostics', 'vmss diagnostics']:
        with self.argument_context(scope) as c:
            c.argument('version', help='version of the diagnostics extension. Will use the latest if not specfied')
            c.argument('settings', help='json string or a file path, which defines data to be collected.', type=validate_file_or_dict, completer=FilesCompleter())
            c.argument('protected_settings', help='json string or a file path containing private configurations such as storage account keys, etc.', type=validate_file_or_dict, completer=FilesCompleter())
            c.argument('is_windows_os', action='store_true', help='for Windows VMs')

    for scope in ['vm encryption', 'vmss encryption']:
        with self.argument_context(scope) as c:
            c.argument('volume_type', help='Type of volume that the encryption operation is performed on', arg_type=get_enum_type(['DATA', 'OS', 'ALL']))
            c.argument('force', action='store_true', help='continue by ignoring client side validation errors')
            c.argument('disk_encryption_keyvault', help='Name or ID of the key vault where the generated encryption key will be placed.')
            c.argument('key_encryption_key', help='Key vault key name or URL used to encrypt the disk encryption key.')
            c.argument('key_encryption_keyvault', help='Name or ID of the key vault containing the key encryption key used to encrypt the disk encryption key. If missing, CLI will use `--disk-encryption-keyvault`.')

    for scope in ['vm extension', 'vmss extension']:
        with self.argument_context(scope) as c:
            c.argument('publisher', help='The name of the extension publisher.')
            c.argument('settings', type=validate_file_or_dict, help='Extension settings in JSON format. A JSON file path is also accepted.')
            c.argument('protected_settings', type=validate_file_or_dict, help='Protected settings in JSON format for sensitive information like credentials. A JSON file path is also accepted.')
            c.argument('version', help='The version of the extension')

    with self.argument_context('vm extension set') as c:
        c.argument('force_update', action='store_true', help='force to update even if the extension configuration has not changed.')
        c.argument('extension_instance_name', extension_instance_name_type, arg_group='Resource Id')

    with self.argument_context('vmss extension set', min_api='2017-12-01') as c:
        c.argument('force_update', action='store_true', help='force to update even if the extension configuration has not changed.')
        c.argument('extension_instance_name', extension_instance_name_type)
        c.argument('provision_after_extensions', nargs='+', help='Space-separated list of extension names after which this extension should be provisioned. These extensions must already be set on the vm.')

    for scope in ['vm extension image', 'vmss extension image']:
        with self.argument_context(scope) as c:
            c.argument('image_location', options_list=['--location', '-l'], help='Image location.')
            c.argument('name', help='Image name', id_part=None)
            c.argument('publisher_name', options_list=['--publisher', '-p'], help='Image publisher name')
            c.argument('type', options_list=['--name', '-n'], help='Name of the extension')
            c.argument('latest', action='store_true', help='Show the latest version only.')
            c.argument('version', help='Extension version')
            c.argument('orderby', help="the $orderby odata query option")
            c.argument('top', help='the $top odata query option')

    for scope in ['vm create', 'vm update', 'vmss create', 'vmss update']:
        with self.argument_context(scope) as c:
            license_msg = "Specifies that the Windows image or disk was licensed on-premises. " \
                          "To enable Azure Hybrid Benefit for Windows Server, use 'Windows_Server'. " \
                          "To enable Multitenant Hosting Rights for Windows 10, use 'Windows_Client'. " \
                          "For more information see the Azure Windows VM online docs."
            c.argument('license_type', help=license_msg, arg_type=get_enum_type(['Windows_Server', 'Windows_Client', 'None']))

    with self.argument_context('sig') as c:
        c.argument('gallery_name', options_list=['--gallery-name', '-r'], help='gallery name')
        c.argument('gallery_image_name', options_list=['--gallery-image-definition', '-i'], help='gallery image definition')
        c.argument('gallery_image_version', options_list=['--gallery-image-version', '-e'], help='gallery image version')

    for scope in ['sig show', 'sig image-definition show', 'sig image-definition delete']:
        with self.argument_context(scope) as c:
            c.argument('gallery_name', options_list=['--gallery-name', '-r'], id_part='name', help='gallery name')
            c.argument('gallery_image_name', options_list=['--gallery-image-definition', '-i'], id_part='child_name_1', help='gallery image definition')

    with self.argument_context('sig image-definition create') as c:
        c.argument('offer', options_list=['--offer', '-f'], help='image offer')
        c.argument('sku', options_list=['--sku', '-s'], help='image sku')
        c.argument('publisher', options_list=['--publisher', '-p'], help='image publisher')
        c.argument('os_type', arg_type=get_enum_type(['Windows', 'Linux']), help='the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD')
        c.ignore('os_state')  # service is not ready
        c.argument('minimum_cpu_core', type=int, arg_group='Recommendation', help='minimum cpu cores')
        c.argument('maximum_cpu_core', type=int, arg_group='Recommendation', help='maximum cpu cores')
        c.argument('minimum_memory', type=int, arg_group='Recommendation', help='minimum memory in MB')
        c.argument('maximum_memory', type=int, arg_group='Recommendation', help='maximum memory in MB')

        c.argument('plan_publisher', help='plan publisher', arg_group='Purchase plan')
        c.argument('plan_name', help='plan name', arg_group='Purchase plan')
        c.argument('plan_product', help='plan product', arg_group='Purchase plan')

        c.argument('eula', help='The Eula agreement for the gallery image')
        c.argument('privacy_statement_uri', help='The privacy statement uri')
        c.argument('release_note_uri', help='The release note uri')
        c.argument('end_of_life_date', help="the end of life date, e.g. '2020-12-31'")
        c.argument('disallowed_disk_types', nargs='*', help='disk types which would not work with the image, e.g., Standard_LRS')

    with self.argument_context('sig create') as c:
        c.argument('description', help='the description of the gallery')
    with self.argument_context('sig update') as c:
        c.ignore('gallery')
    with self.argument_context('sig image-definition create') as c:
        c.argument('description', help='the description of the gallery image definition')
    with self.argument_context('sig image-definition update') as c:
        c.ignore('gallery_image')

    with self.argument_context('sig image-version') as c:
        deprecated_option = c.deprecate(target='--gallery-image-version-name', redirect='--gallery-image-version', hide=True, expiration="2.1.0")
        c.argument('gallery_image_version_name', options_list=['--gallery-image-version', '-e', deprecated_option], )

    with self.argument_context('sig image-version create') as c:
        c.argument('gallery_image_version', options_list=['--gallery-image-version', '-e'],
                   help='Gallery image version in semantic version pattern. The allowed characters are digit and period. Digits must be within the range of a 32-bit integer, e.g. <MajorVersion>.<MinorVersion>.<Patch>')
        c.argument('description', help='the description of the gallery image version')
        c.argument('managed_image', help='image name(if in the same resource group) or resource id')
        c.argument('exclude_from_latest', arg_type=get_three_state_flag(), help='The flag means that if it is set to true, people deploying VMs with version omitted will not use this version.')
        c.argument('version', help='image version')
        c.argument('end_of_life_date', help="the end of life date, e.g. '2020-12-31'")

    with self.argument_context('sig image-version show') as c:
        c.argument('expand', help="The expand expression to apply on the operation, e.g. 'ReplicationStatus'")
    for scope in ['sig image-version create', 'sig image-version update']:
        with self.argument_context(scope) as c:
            c.argument('target_regions', nargs='*', validator=process_gallery_image_version_namespace,
                       help='Space-separated list of regions and their replica counts. Use "<region>=<replica count>" to set the replica count for each region. If only the region is specified, the default replica count will be used.')
            c.argument('replica_count', help='The default number of replicas to be created per region. To set regional replication counts, use --target-regions', type=int)
示例#33
0
def load_arguments(self, _):

    with self.argument_context('sql') as c:
        c.argument('location_name', arg_type=get_location_type(self.cli_ctx))
        c.argument('usage_name', options_list=['--usage', '-u'])
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('sql db') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('database_name',
                   options_list=['--name', '-n'],
                   help='Name of the Azure SQL Database.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        c.argument('max_size_bytes',
                   arg_type=max_size_bytes_param_type)

        creation_arg_group = 'Creation'

        c.argument('collation',
                   arg_group=creation_arg_group)

        c.argument('catalog_collation',
                   arg_group=creation_arg_group,
                   arg_type=get_enum_type(CatalogCollationType))

        c.argument('sample_name',
                   arg_group=creation_arg_group)

        c.argument('license_type',
                   arg_type=get_enum_type(DatabaseLicenseType))

        # Needs testing
        c.ignore('read_scale')
        # c.argument('read_scale',
        #            arg_type=get_three_state_flag(DatabaseReadScale.enabled.value,
        #                                         DatabaseReadScale.disabled.value,
        #                                         return_label=True))

        c.argument('zone_redundant',
                   arg_type=zone_redundant_param_type)

        c.argument('tier',
                   arg_type=tier_param_type,
                   help='The edition component of the sku. Allowed values include: Basic, Standard, '
                   'Premium, GeneralPurpose, BusinessCritical.')

        c.argument('capacity',
                   arg_type=capacity_param_type,
                   arg_group=sku_component_arg_group,
                   help='The capacity component of the sku in integer number of DTUs or vcores.')

        c.argument('family',
                   arg_type=family_param_type,
                   help='The compute generation component of the sku (for vcore skus only). '
                   'Allowed values include: Gen4, Gen5.')

    with self.argument_context('sql db create') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.default)

    with self.argument_context('sql db copy') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.copy)

        c.argument('dest_name',
                   help='Name of the database that will be created as the copy destination.')

        c.argument('dest_resource_group_name',
                   options_list=['--dest-resource-group'],
                   help='Name of the resouce group to create the copy in.'
                   ' If unspecified, defaults to the origin resource group.')

        c.argument('dest_server_name',
                   options_list=['--dest-server'],
                   help='Name of the server to create the copy in.'
                   ' If unspecified, defaults to the origin server.')

    with self.argument_context('sql db rename') as c:
        c.argument('new_name',
                   help='The new name that the database will be renamed to.')

    with self.argument_context('sql db restore') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.point_in_time_restore)

        c.argument('dest_name',
                   help='Name of the database that will be created as the restore destination.')

        restore_point_arg_group = 'Restore Point'

        c.argument('restore_point_in_time',
                   options_list=['--time', '-t'],
                   arg_group=restore_point_arg_group,
                   help='The point in time of the source database that will be restored to create the'
                   ' new database. Must be greater than or equal to the source database\'s'
                   ' earliestRestoreDate value. Either --time or --deleted-time (or both) must be specified.')

        c.argument('source_database_deletion_date',
                   options_list=['--deleted-time'],
                   arg_group=restore_point_arg_group,
                   help='If specified, restore from a deleted database instead of from an existing database.'
                   ' Must match the deleted time of a deleted database in the same server.'
                   ' Either --time or --deleted-time (or both) must be specified.')

    with self.argument_context('sql db show') as c:
        # Service tier advisors and transparent data encryption are not included in the first batch
        # of GA commands.
        c.ignore('expand')

    with self.argument_context('sql db list') as c:
        c.argument('elastic_pool_name',
                   options_list=['--elastic-pool'],
                   help='If specified, lists only the databases in this elastic pool')

    with self.argument_context('sql db list-editions') as c:
        c.argument('show_details',
                   options_list=['--show-details', '-d'],
                   help='List of additional details to include in output.',
                   nargs='+',
                   arg_type=get_enum_type(DatabaseCapabilitiesAdditionalDetails))

        c.argument('available', arg_type=available_param_type)

        search_arg_group = 'Search'

        # We could used get_enum_type here, but that will validate the inputs which means there
        # will be no way to query for new editions/service objectives that are made available after
        # this version of CLI is released.
        c.argument('edition',
                   arg_type=tier_param_type,
                   arg_group=search_arg_group,
                   help='Edition to search for. If unspecified, all editions are shown.')

        c.argument('service_objective',
                   arg_group=search_arg_group,
                   help='Service objective to search for. If unspecified, all service objectives are shown.')

        c.argument('dtu',
                   arg_group=search_arg_group,
                   help='Number of DTUs to search for. If unspecified, all DTU sizes are shown.')

        c.argument('vcores',
                   arg_group=search_arg_group,
                   help='Number of vcores to search for. If unspecified, all vcore sizes are shown.')

    with self.argument_context('sql db update') as c:
        c.argument('service_objective',
                   arg_group=sku_arg_group,
                   help='The name of the new service objective. If this is a standalone db service'
                   ' objective and the db is currently in an elastic pool, then the db is removed from'
                   ' the pool.')

        c.argument('elastic_pool_id',
                   arg_type=elastic_pool_id_param_type,
                   help='The name or resource id of the elastic pool to move the database into.')

        c.argument('max_size_bytes', help='The new maximum size of the database expressed in bytes.')

    with self.argument_context('sql db export') as c:
        # Create args that will be used to build up the ExportRequest object
        create_args_for_complex_type(
            c, 'parameters', ExportRequest, [
                'administrator_login',
                'administrator_login_password',
                'authentication_type',
                'storage_key',
                'storage_key_type',
                'storage_uri',
            ])

        c.argument('administrator_login',
                   options_list=['--admin-user', '-u'])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument('authentication_type',
                   options_list=['--auth-type', '-a'],
                   arg_type=get_enum_type(AuthenticationType))

        c.argument('storage_key_type',
                   arg_type=get_enum_type(StorageKeyType))

    with self.argument_context('sql db import') as c:
        # Create args that will be used to build up the ImportExtensionRequest object
        create_args_for_complex_type(c, 'parameters', ImportExtensionRequest, [
            'administrator_login',
            'administrator_login_password',
            'authentication_type',
            'storage_key',
            'storage_key_type',
            'storage_uri'
        ])

        c.argument('administrator_login',
                   options_list=['--admin-user', '-u'])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument('authentication_type',
                   options_list=['--auth-type', '-a'],
                   arg_type=get_enum_type(AuthenticationType))

        c.argument('storage_key_type',
                   arg_type=get_enum_type(StorageKeyType))

        # The parameter name '--name' is used for 'database_name', so we need to give a different name
        # for the import extension 'name' parameter to avoid conflicts. This parameter is actually not
        # needed, but we still need to avoid this conflict.
        c.argument('name', options_list=['--not-name'], arg_type=ignore_type)

    with self.argument_context('sql db show-connection-string') as c:
        c.argument('client_provider',
                   options_list=['--client', '-c'],
                   help='Type of client connection provider.',
                   arg_type=get_enum_type(ClientType))

        auth_group = 'Authentication'

        c.argument('auth_type',
                   options_list=['--auth-type', '-a'],
                   arg_group=auth_group,
                   help='Type of authentication.',
                   arg_type=get_enum_type(ClientAuthenticationType))

    #####
    #           sql db op
    #####
    with self.argument_context('sql db op') as c:
        c.argument('database_name',
                   options_list=['--database', '-d'],
                   required=True,
                   help='Name of the Azure SQL Database.')

        c.argument('operation_id',
                   options_list=['--name', '-n'],
                   required=True,
                   help='The unique name of the operation to cancel.')

    #####
    #           sql db replica
    #####
    with self.argument_context('sql db replica create') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.secondary)

        c.argument('partner_resource_group_name',
                   options_list=['--partner-resource-group'],
                   help='Name of the resource group to create the new replica in.'
                   ' If unspecified, defaults to the origin resource group.')

        c.argument('partner_server_name',
                   options_list=['--partner-server'],
                   help='Name of the server to create the new replica in.')

    with self.argument_context('sql db replica set-primary') as c:
        c.argument('database_name',
                   help='Name of the database to fail over.')

        c.argument('server_name',
                   help='Name of the server containing the secondary replica that will become'
                   ' the new primary. ' + server_configure_help)

        c.argument('resource_group_name',
                   help='Name of the resource group containing the secondary replica that'
                   ' will become the new primary.')

        c.argument('allow_data_loss',
                   help='If specified, the failover operation will allow data loss.')

    with self.argument_context('sql db replica delete-link') as c:
        c.argument('partner_server_name',
                   options_list=['--partner-server'],
                   help='Name of the server that the other replica is in.')

        c.argument('partner_resource_group_name',
                   options_list=['--partner-resource-group'],
                   help='Name of the resource group that the other replica is in. If unspecified,'
                   ' defaults to the first database\'s resource group.')

    #####
    #           sql db audit-policy & threat-policy
    #####
    def _configure_security_policy_storage_params(arg_ctx):
        storage_arg_group = 'Storage'

        arg_ctx.argument('storage_account',
                         options_list=['--storage-account'],
                         arg_group=storage_arg_group,
                         help='Name of the storage account.')

        arg_ctx.argument('storage_account_access_key',
                         options_list=['--storage-key'],
                         arg_group=storage_arg_group,
                         help='Access key for the storage account.')

        arg_ctx.argument('storage_endpoint',
                         arg_group=storage_arg_group,
                         help='The storage account endpoint.')

    with self.argument_context('sql db audit-policy update') as c:
        _configure_security_policy_storage_params(c)

        policy_arg_group = 'Policy'

        c.argument('state',
                   arg_group=policy_arg_group,
                   help='Auditing policy state',
                   arg_type=get_enum_type(BlobAuditingPolicyState))

        c.argument('audit_actions_and_groups',
                   options_list=['--actions'],
                   arg_group=policy_arg_group,
                   help='List of actions and action groups to audit.',
                   nargs='+')

        c.argument('retention_days',
                   arg_group=policy_arg_group,
                   help='The number of days to retain audit logs.')

    with self.argument_context('sql db threat-policy update') as c:
        _configure_security_policy_storage_params(c)

        policy_arg_group = 'Policy'
        notification_arg_group = 'Notification'

        c.argument('state',
                   arg_group=policy_arg_group,
                   help='Threat detection policy state',
                   arg_type=get_enum_type(SecurityAlertPolicyState))

        c.argument('retention_days',
                   arg_group=policy_arg_group,
                   help='The number of days to retain threat detection logs.')

        c.argument('disabled_alerts',
                   arg_group=policy_arg_group,
                   options_list=['--disabled-alerts'],
                   help='List of disabled alerts.',
                   nargs='+')

        c.argument('email_addresses',
                   arg_group=notification_arg_group,
                   options_list=['--email-addresses'],
                   help='List of email addresses that alerts are sent to.',
                   nargs='+')

        c.argument('email_account_admins',
                   arg_group=notification_arg_group,
                   options_list=['--email-account-admins'],
                   help='Whether the alert is sent to the account administrators.',
                   arg_type=get_enum_type(SecurityAlertPolicyEmailAccountAdmins))

        # TODO: use server default

    #####
    #           sql db transparent-data-encryption
    #####
    with self.argument_context('sql db tde') as c:
        c.argument('database_name',
                   options_list=['--database', '-d'],
                   required=True,
                   help='Name of the Azure SQL Database.')

    with self.argument_context('sql db tde set') as c:
        c.argument('status',
                   options_list=['--status'],
                   required=True,
                   help='Status of the transparent data encryption.',
                   arg_type=get_enum_type(TransparentDataEncryptionStatus))

    ###############################################
    #                sql dw                       #
    ###############################################
    with self.argument_context('sql dw') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('database_name',
                   options_list=['--name', '-n'],
                   help='Name of the data warehouse.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        c.argument('max_size_bytes',
                   arg_type=max_size_bytes_param_type)

        c.argument('service_objective',
                   help='The service objective of the data warehouse. For example: ' +
                   dw_service_objective_examples)

        c.argument('collation',
                   help='The collation of the data warehouse.')

    with self.argument_context('sql dw create') as c:
        _configure_db_create_params(c, Engine.dw, CreateMode.default)

    with self.argument_context('sql dw show') as c:
        # Service tier advisors and transparent data encryption are not included in the first batch
        # of GA commands.
        c.ignore('expand')

    # Data Warehouse restore will not be included in the first batch of GA commands
    # (list_restore_points also applies to db, but it's not very useful. It's
    # mainly useful for dw.)
    # with ParametersContext(command='sql dw restore-point') as c:
    #     c.register_alias('database_name', ('--database', '-d'))

    ###############################################
    #                sql elastic-pool             #
    ###############################################
    with self.argument_context('sql elastic-pool') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('elastic_pool_name',
                   options_list=['--name', '-n'],
                   help='The name of the elastic pool.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        # --db-dtu-max and --db-dtu-min were the original param names, which is consistent with the
        # 2014-04-01 REST API.
        # --db-max-dtu and --db-min-dtu are aliases which are consistent with the `sql elastic-pool
        # list-editions --show-details db-max-dtu db-min-dtu` parameter values. These are more
        # consistent with other az sql commands, but the original can't be removed due to
        # compatibility.
        c.argument('max_capacity',
                   options_list=['--db-dtu-max', '--db-max-dtu', '--db-max-capacity'],
                   help='The maximum capacity (in DTUs or vcores) any one database can consume.')

        c.argument('min_capacity',
                   options_list=['--db-dtu-min', '--db-min-dtu', '--db-min-capacity'],
                   help='The minumum capacity (in DTUs or vcores) each database is guaranteed.')

        # --storage was the original param name, which is consistent with the underlying REST API.
        # --max-size is an alias which is consistent with the `sql elastic-pool list-editions
        # --show-details max-size` parameter value and also matches `sql db --max-size` parameter name.
        c.argument('max_size_bytes',
                   arg_type=max_size_bytes_param_type,
                   options_list=['--max-size', '--storage'])

        c.argument('license_type',
                   arg_type=get_enum_type(ElasticPoolLicenseType))

        c.argument('zone_redundant',
                   arg_type=zone_redundant_param_type)

        c.argument('tier',
                   arg_type=tier_param_type,
                   help='The edition component of the sku. Allowed values include: Basic, Standard, '
                   'Premium, GeneralPurpose, BusinessCritical.')

        c.argument('capacity',
                   arg_type=capacity_or_dtu_param_type,
                   help='The capacity component of the sku in integer number of DTUs or vcores.')

        c.argument('family',
                   arg_type=family_param_type,
                   help='The compute generation component of the sku (for vcore skus only). '
                   'Allowed values include: Gen4, Gen5.')

    with self.argument_context('sql elastic-pool create') as c:
        # Create args that will be used to build up the ElasticPool object
        create_args_for_complex_type(
            c, 'parameters', ElasticPool, [
                'license_type',
                'max_size_bytes',
                'name',
                'per_database_settings',
                'tags',
                'zone_redundant',
            ])

        # Create args that will be used to build up the ElasticPoolPerDatabaseSettings object
        create_args_for_complex_type(
            c, 'per_database_settings', ElasticPoolPerDatabaseSettings, [
                'max_capacity',
                'min_capacity',
            ])

        # Create args that will be used to build up the ElasticPool Sku object
        create_args_for_complex_type(
            c, 'sku', Sku, [
                'capacity',
                'family',
                'name',
                'tier',
            ])

        c.ignore('name')  # Hide sku name

    with self.argument_context('sql elastic-pool list-editions') as c:
        # Note that `ElasticPoolCapabilitiesAdditionalDetails` intentionally match param names to
        # other commands, such as `sql elastic-pool create --db-max-dtu --db-min-dtu --max-size`.
        c.argument('show_details',
                   options_list=['--show-details', '-d'],
                   help='List of additional details to include in output.',
                   nargs='+',
                   arg_type=get_enum_type(ElasticPoolCapabilitiesAdditionalDetails))

        c.argument('available',
                   arg_type=available_param_type)

        search_arg_group = 'Search'

        # We could used 'arg_type=get_enum_type' here, but that will validate the inputs which means there
        # will be no way to query for new editions that are made available after
        # this version of CLI is released.
        c.argument('edition',
                   arg_type=tier_param_type,
                   arg_group=search_arg_group,
                   help='Edition to search for. If unspecified, all editions are shown.')

        c.argument('dtu',
                   arg_group=search_arg_group,
                   help='Number of DTUs to search for. If unspecified, all DTU sizes are shown.')

        c.argument('vcores',
                   arg_group=search_arg_group,
                   help='Number of vcores to search for. If unspecified, all vcore sizes are shown.')

    with self.argument_context('sql elastic-pool update') as c:
        c.argument('database_dtu_max',
                   help='The maximum DTU any one database can consume.')

        c.argument('database_dtu_min',
                   help='The minimum DTU all databases are guaranteed.')

        c.argument('storage_mb',
                   help='Storage limit for the elastic pool in MB.')

    #####
    #           sql elastic-pool op
    #####
    with self.argument_context('sql elastic-pool op') as c:
        c.argument('elastic_pool_name',
                   options_list=['--elastic-pool'],
                   help='Name of the Azure SQL Elastic Pool.')

        c.argument('operation_id',
                   options_list=['--name', '-n'],
                   help='The unique name of the operation to cancel.')

    ###############################################
    #             sql failover-group              #
    ###############################################

    with self.argument_context('sql failover-group') as c:
        c.argument('failover_group_name', options_list=['--name', '-n'], help="The name of the Failover Group")
        c.argument('server_name', arg_type=server_param_type)
        c.argument('partner_server', help="The name of the partner server of a Failover Group")
        c.argument('partner_resource_group', help="The name of the resource group of the partner server")
        c.argument('failover_policy', help="The failover policy of the Failover Group",
                   arg_type=get_enum_type(FailoverPolicyType))
        c.argument('grace_period',
                   help='Interval in hours before automatic failover is initiated '
                        'if an outage occurs on the primary server. '
                        'This indicates that Azure SQL Database will not initiate '
                        'automatic failover before the grace period expires. '
                        'Please note that failover operation with AllowDataLoss option '
                        'might cause data loss due to the nature of asynchronous synchronization.')
        c.argument('add_db', nargs='+',
                   help='List of databases to add to Failover Group')
        c.argument('remove_db', nargs='+',
                   help='List of databases to remove from Failover Group')
        c.argument('allow-data-loss',
                   help='Complete the failover even if doing so may result in data loss. '
                        'This will allow the failover to proceed even if a primary database is unavailable.')

    ###############################################
    #                sql server                   #
    ###############################################
    with self.argument_context('sql server') as c:
        c.argument('server_name',
                   arg_type=server_param_type,
                   options_list=['--name', '-n'])

        c.argument('administrator_login',
                   options_list=['--admin-user', '-u'])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument('assign_identity',
                   options_list=['--assign_identity', '-i'],
                   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('sql server create') as c:
        # Create args that will be used to build up the Server object
        create_args_for_complex_type(
            c, 'parameters', Server, [
                'administrator_login',
                'administrator_login_password',
                'location'
            ])

        c.argument('administrator_login',
                   required=True)

        c.argument('administrator_login_password',
                   required=True)

        c.argument('assign_identity',
                   options_list=['--assign-identity', '-i'],
                   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('sql server update') as c:
        c.argument('administrator_login_password',
                   help='The administrator login password.')

    #####
    #           sql server ad-admin
    ######
    with self.argument_context('sql server ad-admin') as c:
        # The options list should be ['--server', '-s'], but in the originally released version it was
        # ['--server-name'] which we must keep for backward compatibility - but we should deprecate it.
        c.argument('server_name',
                   options_list=['--server-name', '--server', '-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 ')

        c.ignore('tenant_id')

    with self.argument_context('sql server ad-admin create') as c:
        # Create args that will be used to build up the ServerAzureADAdministrator object
        create_args_for_complex_type(
            c, 'properties', ServerAzureADAdministrator, [
                'login',
                'sid',
            ])

    #####
    #           sql server conn-policy
    #####
    with self.argument_context('sql server conn-policy') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('connection_type',
                   options_list=['--connection-type', '-t'],
                   arg_type=get_enum_type(ServerConnectionType))

    #####
    #           sql server dns-alias
    #####
    with self.argument_context('sql server dns-alias') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('dns_alias_name',
                   options_list=('--name', '-n'))

        c.argument('original_server_name',
                   options_list=('--original-server'),
                   help='The name of the server to which alias is currently pointing')

        c.argument('original_resource_group_name',
                   options_list=('--original-resource-group'))

        c.argument('original_subscription_id',
                   options_list=('--original-subscription-id'))

    #####
    #           sql server firewall-rule
    #####
    with self.argument_context('sql server firewall-rule') as c:
        # Help text needs to be specified because 'sql server firewall-rule update' is a custom
        # command.
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('firewall_rule_name',
                   options_list=['--name', '-n'],
                   help='The name of the firewall rule.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        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.')

    #####
    #           sql server key
    #####
    with self.argument_context('sql server key') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('key_name',
                   options_list=['--name', '-n'])

        c.argument('kid',
                   options_list=['--kid', '-k'],
                   required=True,
                   help='The Azure Key Vault key identifier of the server key. An example key identifier is '
                   '"https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"')

    #####
    #           sql server tde-key
    #####
    with self.argument_context('sql server tde-key') as c:
        c.argument('server_name',
                   arg_type=server_param_type)

    with self.argument_context('sql server tde-key set') as c:
        c.argument('kid',
                   options_list=['--kid', '-k'],
                   help='The Azure Key Vault key identifier of the server key to be made encryption protector.'
                   'An example key identifier is '
                   '"https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"')

        c.argument('server_key_type',
                   options_list=['--server-key-type', '-t'],
                   help='The type of the server key',
                   arg_type=get_enum_type(ServerKeyType))

    #####
    #           sql server vnet-rule
    #####
    with self.argument_context('sql server vnet-rule') as c:
        # Help text needs to be specified because 'sql server vnet-rule create' is a custom
        # command.
        c.argument('server_name',
                   arg_type=server_param_type)

        c.argument('virtual_network_rule_name',
                   options_list=['--name', '-n'])

        c.argument('virtual_network_subnet_id',
                   options_list=['--subnet'],
                   help='Name or ID of the subnet that allows access to an Azure Sql 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 firewall rule before the virtual network has vnet service endpoint enabled',
                   arg_type=get_three_state_flag())

    with self.argument_context('sql server vnet-rule create') as c:
        c.extra('vnet_name',
                options_list=['--vnet-name'],
                help='The virtual network name')

    ###############################################
    #                sql managed instance         #
    ###############################################
    with self.argument_context('sql mi') as c:
        c.argument('managed_instance_name',
                   help='The managed instance name',
                   options_list=['--name', '-n'],
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')

        c.argument('tier',
                   arg_type=tier_param_type,
                   help='The edition component of the sku. Allowed value is GeneralPurpose.')

        c.argument('family',
                   arg_type=family_param_type,
                   help='The compute generation component of the sku. '
                   'Allowed values include: Gen4, Gen5.')

        c.argument('storage_size_in_gb',
                   options_list=['--storage'],
                   arg_type=storage_param_type,
                   help='The storage size of the managed instance. '
                   'Storage size must be specified in increments of 32 GB')

        c.argument('license_type',
                   arg_type=get_enum_type(DatabaseLicenseType),
                   help='The license type to apply for this managed instance.')

        c.argument('vcores',
                   options_list=['--capacity', '-c'],
                   help='The capacity of the managed instance in vcores.')

    with self.argument_context('sql mi create') as c:
        # Create args that will be used to build up the ManagedInstance object
        create_args_for_complex_type(
            c, 'parameters', ManagedInstance, [
                'administrator_login',
                'administrator_login_password',
                'license_type',
                'virtual_network_subnet_id',
                'vcores',
                'storage_size_in_gb'
            ])

        # Create args that will be used to build up the Managed Instance's Sku object
        create_args_for_complex_type(
            c, 'sku', Sku, [
                'family',
                'name',
                'tier',
            ])

        c.ignore('name')  # Hide sku name

        c.argument('administrator_login',
                   options_list=['--admin-user', '-u'],
                   required=True)

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'],
                   required=True)

        c.extra('vnet_name',
                options_list=['--vnet-name'],
                help='The virtual network name',
                validator=validate_subnet)

        c.argument('virtual_network_subnet_id',
                   options_list=['--subnet'],
                   required=True,
                   help='Name or ID of the subnet that allows access to an Azure Sql Managed Instance. '
                   'If subnet name is provided, --vnet-name must be provided.')

        c.argument('assign_identity',
                   options_list=['--assign-identity', '-i'],
                   help='Generate and assign an Azure Active Directory Identity for this managed instance '
                   'for use with key management services like Azure KeyVault.')

    with self.argument_context('sql mi update') as c:
        # Create args that will be used to build up the ManagedInstance object
        create_args_for_complex_type(
            c, 'parameters', ManagedInstance, [
                'administrator_login_password',
            ])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument('assign_identity',
                   options_list=['--assign-identity', '-i'],
                   help='Generate and assign an Azure Active Directory Identity for this managed instance '
                   'for use with key management services like Azure KeyVault. '
                   'If identity is already assigned - do nothing.')

    ###############################################
    #                sql managed db               #
    ###############################################
    with self.argument_context('sql midb') as c:
        c.argument('managed_instance_name',
                   arg_type=managed_instance_param_type,
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')

        c.argument('database_name',
                   options_list=['--name', '-n'],
                   help='The name of the Azure SQL Managed Database.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

    with self.argument_context('sql midb create') as c:
        create_args_for_complex_type(
            c, 'parameters', ManagedDatabase, [
                'collation',
            ])

        c.argument('collation',
                   required=False,
                   help='The collation of the Azure SQL Managed Database collation to use, '
                   'e.g.: SQL_Latin1_General_CP1_CI_AS or Latin1_General_100_CS_AS_SC')

    with self.argument_context('sql midb restore') as c:
        create_args_for_complex_type(
            c, 'parameters', ManagedDatabase, [
                'target_managed_database_name',
                'target_managed_instance_name',
                'restore_point_in_time'
            ])

        c.argument('target_managed_database_name',
                   options_list=['--dest-name'],
                   required=True,
                   help='Name of the managed database that will be created as the restore destination.')

        c.argument('target_managed_instance_name',
                   options_list=['--dest-mi'],
                   help='Name of the managed instance to restore managed database to. '
                   'This can be same managed instance, or another managed instance on same subscription. '
                   'When not specified it defaults to source managed instance.')

        c.argument('target_resource_group_name',
                   options_list=['--dest-resource-group'],
                   help='Name of the resource group of the managed instance to restore managed database to. '
                   'When not specified it defaults to source resource group.')

        restore_point_arg_group = 'Restore Point'

        c.argument('restore_point_in_time',
                   options_list=['--time', '-t'],
                   arg_group=restore_point_arg_group,
                   required=True,
                   help='The point in time of the source database that will be restored to create the'
                   ' new database. Must be greater than or equal to the source database\'s'
                   ' earliestRestoreDate value. Time should be in following format: "YYYY-MM-DDTHH:MM:SS"')

    with self.argument_context('sql midb list') as c:
        c.argument('managed_instance_name', id_part=None)
示例#34
0
def load_arguments(self, _):
    from azure.mgmt.monitor.models.monitor_management_client_enums import ConditionOperator, TimeAggregationOperator

    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    webhook_prop_type = CLIArgumentType(validator=process_webhook_prop, nargs='*')

    autoscale_name_type = CLIArgumentType(options_list=['--autoscale-name'], help='Name of the autoscale settings.', id_part='name')
    autoscale_profile_name_type = CLIArgumentType(options_list=['--profile-name'], help='Name of the autoscale profile.')
    autoscale_rule_name_type = CLIArgumentType(options_list=['--rule-name'], help='Name of the autoscale rule.')

    with self.argument_context('monitor') as c:
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)

    # region Alerts
    with self.argument_context('monitor alert') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')

    with self.argument_context('monitor alert create') as c:
        c.resource_parameter('target', arg_group='Target Resource', alias='target', preserve_resource_group_parameter=True)
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('condition', action=ConditionAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Action') as c:
        c.argument('custom_emails', nargs='+')
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('actions', options_list=['--action', '-a'], action=AlertAddAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Condition') as c:
        c.argument('metric_name')
        c.argument('operator', arg_type=get_enum_type(ConditionOperator))
        c.argument('threshold')
        c.argument('time_aggregation', arg_type=get_enum_type(TimeAggregationOperator))
        c.argument('window_size')

    with self.argument_context('monitor alert update') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.resource_parameter('target', arg_group='Target Resource', required=False, preserve_resource_group_parameter=True)

    with self.argument_context('monitor alert update', arg_group='Action') as c:
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('add_actions', options_list=['--add-action', '-a'], nargs='+', action=AlertAddAction)
        c.argument('remove_actions', options_list=['--remove-action', '-r'], nargs='+', action=AlertRemoveAction)

    with self.argument_context('monitor alert update', arg_group='Condition') as c:
        c.argument('condition', action=ConditionAction, nargs='+')
        c.argument('metric')
        c.argument('operator', arg_type=get_enum_type(get_operator_map().keys()))
        c.argument('threshold')
        c.argument('aggregation', arg_type=get_enum_type(get_aggregation_map().keys()))
        c.argument('period', type=period_type)

    for scope in ['monitor alert show-incident', 'monitor alert list-incidents']:
        with self.argument_context(scope) as c:
            c.argument('rule_name', options_list=['--rule-name'], id_part='name')
            c.argument('incident_name', name_arg_type, id_part='child_name_1')

    with self.argument_context('monitor alert list-incidents') as c:
        c.argument('rule_name', options_list=['--rule-name'], id_part=None)
    # endregion

    # region Metrics
    with self.argument_context('monitor metrics') as c:
        c.argument('metricnamespace', options_list=['--namespace'], help='Namespace to query metric definitions for.')

    with self.argument_context('monitor metrics list-definitions') as c:
        c.resource_parameter('resource_uri', arg_group='Target Resource')

    with self.argument_context('monitor metrics list') as c:
        from .validators import (process_metric_timespan, process_metric_aggregation, process_metric_result_type,
                                 process_metric_dimension, validate_metric_names)
        from azure.mgmt.monitor.models.monitor_management_client_enums import AggregationType
        c.resource_parameter('resource_uri', arg_group='Target Resource')
        c.extra('start_time', options_list=['--start-time'], validator=process_metric_timespan, arg_group='Time')
        c.extra('end_time', options_list=['--end-time'], arg_group='Time')
        c.extra('metadata', options_list=['--metadata'], action='store_true', validator=process_metric_result_type)
        c.extra('dimension', options_list=['--dimension'], nargs='*', validator=process_metric_dimension)
        c.argument('interval', arg_group='Time')
        c.argument('aggregation', arg_type=get_enum_type(t for t in AggregationType if t.name != 'none'), nargs='*', validator=process_metric_aggregation)
        c.argument('metricnames', options_list=['--metrics'], nargs='+', help='Space-separated list of metric names to retrieve.', validator=validate_metric_names)
        c.ignore('timespan', 'result_type')
    # endregion

    # region Autoscale
    with self.argument_context('monitor autoscale') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('autoscale_setting_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('profile_name', arg_type=autoscale_profile_name_type)
        c.argument('rule_name', arg_type=autoscale_rule_name_type)
        c.argument('enabled', arg_type=get_three_state_flag(), help='Autoscale settings enabled status.')

    with self.argument_context('monitor autoscale', arg_group='Notification') as c:
        c.argument('actions', options_list=['--action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('add_actions', options_list=['--add-action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('remove_actions', options_list=['--remove-action', '-r'], action=AutoscaleRemoveAction, nargs='+')
        c.argument('email_administrator', arg_type=get_three_state_flag(), help='Send email to subscription administrator on scaling.')
        c.argument('email_coadministrators', arg_type=get_three_state_flag(), help='Send email to subscription co-administrators on scaling.')

    with self.argument_context('monitor autoscale create') as c:
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create the autoscale settings in a disabled state.')

    with self.argument_context('monitor autoscale', arg_group='Instance Limit') as c:
        c.argument('count', type=int, help='The numer of instances to use. If used with --min/max-count, the default number of instances to use.')
        c.argument('min_count', type=int, help='The minimum number of instances.')
        c.argument('max_count', type=int, help='The maximum number of instances.')

    with self.argument_context('monitor autoscale profile') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('profile_name', arg_type=autoscale_profile_name_type, options_list=['--name', '-n'])
        c.argument('copy_rules', help='Name of an existing schedule from which to copy the scaling rules for the new schedule.')

    with self.argument_context('monitor autoscale profile list-timezones') as c:
        c.argument('search_query', options_list=['--search-query', '-q'], help='Query text to find.')
        c.argument('offset', help='Filter results based on UTC hour offset.', type=timezone_offset_type)

    with self.argument_context('monitor autoscale profile', arg_group='Schedule') as c:
        c.argument('timezone', type=timezone_name_type)
        c.argument('start', arg_type=get_datetime_type(help='Start time.', timezone=False))
        c.argument('end', arg_type=get_datetime_type(help='End time.', timezone=False))
        c.argument('recurrence', options_list=['--recurrence', '-r'], nargs='+', validator=validate_autoscale_recurrence)

    with self.argument_context('monitor autoscale rule') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('rule_name', arg_type=autoscale_rule_name_type, options_list=['--name', '-n'])
        c.argument('scale', help='The direction and amount to scale.', action=AutoscaleScaleAction, nargs='+')
        c.argument('condition', help='Condition on which to scale.', action=AutoscaleConditionAction, nargs='+')
        c.argument('timegrain', validator=validate_autoscale_timegrain, nargs='+')
        c.argument('cooldown', type=int, help='The number of minutes that must elapse before another scaling event can occur.')

    with self.argument_context('monitor autoscale rule delete') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to remove, or '*' to clear all rules.")

    with self.argument_context('monitor autoscale rule copy') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to copy, or '*' to copy all rules.")
        c.argument('source_profile', options_list=['--source-schedule'], help='Name of the profile to copy rules from.')
        c.argument('dest_profile', options_list=['--dest-schedule'], help='Name of the profile to copy rules to.')

    with self.argument_context('monitor autoscale rule create') as c:
        c.resource_parameter('source', arg_group='Source', required=False, preserve_resource_group_parameter=True)
    # endregion

    # region Autoscale (OLD)
    with self.argument_context('monitor autoscale-settings') as c:
        c.argument('name', options_list=['--azure-resource-name'])
        c.argument('autoscale_setting_name', options_list=['--name', '-n'])

    with self.argument_context('monitor autoscale-settings create') as c:
        c.argument('parameters', type=get_json_object, help='JSON encoded parameters configuration. Use @{file} to load from a file. Use az autoscale-settings get-parameters-template to export json template.')

    for scope in ['monitor autoscale-settings show', 'monitor autoscale-settings delete']:
        with self.argument_context(scope) as c:
            c.argument('autoscale_setting_name', id_part='name')

    #  https://github.com/Azure/azure-rest-api-specs/issues/1017
    with self.argument_context('monitor autoscale-settings list') as c:
        c.ignore('filter')
    # endregion

    # region Diagnostic
    with self.argument_context('monitor diagnostic-settings') as c:
        c.argument('name', options_list=('--name', '-n'))

    with self.argument_context('monitor diagnostic-settings show') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings delete') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings update') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings create') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource', skip_validator=True)
        c.argument('logs', type=get_json_object)
        c.argument('metrics', type=get_json_object)

    with self.argument_context('monitor diagnostic-settings categories list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings categories show') as c:
        c.resource_parameter('resource_uri', required=True)
    # endregion

    # region LogProfiles
    with self.argument_context('monitor log-profiles') as c:
        c.argument('log_profile_name', options_list=['--name', '-n'])

    with self.argument_context('monitor log-profiles create') as c:
        c.argument('name', options_list=['--name', '-n'])
        c.argument('categories', nargs='+')
        c.argument('locations', nargs='+')
        c.argument('days', type=int, arg_group='Retention Policy')
        c.argument('enabled', arg_type=get_three_state_flag(), arg_group='Retention Policy')
    # endregion

    # region ActivityLog
    with self.argument_context('monitor activity-log list') as c:
        c.argument('select', nargs='+')

    with self.argument_context('monitor activity-log list', arg_group='OData Filter') as c:
        c.argument('correlation_id')
        c.argument('resource_group')
        c.argument('resource_id')
        c.argument('resource_provider')
        c.argument('start_time')
        c.argument('end_time')
        c.argument('caller')
        c.argument('status')
    # endregion

    # region ActionGroup
    with self.argument_context('monitor action-group') as c:
        c.argument('action_group_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor action-group create') as c:
        from .validators import process_action_group_detail_for_creation
        from .actions import ActionGroupReceiverParameterAction
        c.extra('receivers', options_list=['--action', '-a'], nargs='+', arg_group='Actions', action=ActionGroupReceiverParameterAction, validator=process_action_group_detail_for_creation)
        c.extra('short_name')
        c.extra('tags')
        c.ignore('action_group')

    with self.argument_context('monitor action-group update', arg_group='Actions') as c:
        c.extra('add_receivers', options_list=['--add-action', '-a'], nargs='+', action=ActionGroupReceiverParameterAction)
        c.extra('remove_receivers', options_list=['--remove-action', '-r'], nargs='+')
        c.ignore('action_group')

    with self.argument_context('monitor action-group enable-receiver') as c:
        c.argument('receiver_name', options_list=['--name', '-n'])
        c.argument('action_group_name', options_list=['--action-group'])
    # endregion

    # region ActivityLog Alerts
    with self.argument_context('monitor activity-log alert') as c:
        c.argument('activity_log_alert_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor activity-log alert create') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('disable', action='store_true')
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('action_groups', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert update-condition') as c:
        c.argument('reset', action='store_true')
        c.argument('add_conditions', options_list=['--add-condition', '-a'], nargs='+')
        c.argument('remove_conditions', options_list=['--remove-condition', '-r'], nargs='+')

    with self.argument_context('monitor activity-log alert update') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('enabled', arg_type=get_three_state_flag())

    with self.argument_context('monitor activity-log alert action-group add') as c:
        c.argument('reset', action='store_true')
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert action-group remove') as c:
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')

    with self.argument_context('monitor activity-log alert scope add') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('reset', action='store_true')

    with self.argument_context('monitor activity-log alert scope remove') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
示例#35
0
def load_arguments(self, _):  # pylint: disable=too-many-locals, too-many-statements
    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], id_part='name', help='The name of the Azure Media Services account.', metavar='NAME')
    account_name_arg_type = CLIArgumentType(options_list=['--account-name', '-a'], id_part='name', help='The name of the Azure Media Services account.', metavar='ACCOUNT_NAME')
    storage_account_arg_type = CLIArgumentType(options_list=['--storage-account'], validator=validate_storage_account_id, metavar='STORAGE_NAME')
    password_arg_type = CLIArgumentType(options_list=['--password', '-p'], metavar='PASSWORD_NAME')
    transform_name_arg_type = CLIArgumentType(options_list=['--transform-name', '-t'], metavar='TRANSFORM_NAME')
    expiry_arg_type = CLIArgumentType(options_list=['--expiry'], type=datetime_format, metavar='EXPIRY_TIME')
    default_policy_name_arg_type = CLIArgumentType(options_list=['--content-key-policy-name'], help='The default content key policy name used by the streaming locator.', metavar='DEFAULT_CONTENT_KEY_POLICY_NAME')
    archive_window_length_arg_type = CLIArgumentType(options_list=['--archive-window-length'], validator=validate_archive_window_length, metavar='ARCHIVE_WINDOW_LENGTH')
    key_frame_interval_duration_arg_type = CLIArgumentType(options_list=['--key-frame-interval-duration'], validator=validate_archive_window_length, metavar='ARCHIVE_WINDOW_LENGTH')
    correlation_data_type = CLIArgumentType(validator=validate_correlation_data, help="Space-separated correlation data in 'key[=value]' format. This customer provided data will be returned in Job and JobOutput state events.", nargs='*', metavar='CORRELATION_DATA')
    token_claim_type = CLIArgumentType(validator=validate_token_claim, help="Space-separated required token claims in '[key=value]' format.", nargs='*', metavar='ASYMMETRIC TOKEN CLAIMS')
    output_assets_type = CLIArgumentType(validator=validate_output_assets, nargs='*', help="Space-separated assets in 'assetName=label' format. An asset without label can be sent like this: 'assetName='", metavar='OUTPUT_ASSETS')

    with self.argument_context('ams') as c:
        c.argument('account_name', name_arg_type)

    with self.argument_context('ams account') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('ams account create') as c:
        c.argument('storage_account', storage_account_arg_type,
                   help='The name or resource ID of the primary storage account to attach to the Azure Media Services account. The storage account MUST be in the same Azure subscription as the Media Services account. It is strongly recommended that the storage account be in the same resource group as the Media Services account. Blob only accounts are not allowed as primary.')

    with self.argument_context('ams account check-name') as c:
        c.argument('account_name', options_list=['--name', '-n'], id_part=None,
                   help='The name of the Azure Media Services account.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx))

    with self.argument_context('ams account mru') as c:
        c.argument('type', help='Speed of reserved processing units. The cost of media encoding depends on the pricing tier you choose. See https://azure.microsoft.com/pricing/details/media-services/ for further details. Allowed values: {}.'.format(", ".join(get_mru_type_completion_list())))
        c.argument('count', type=int, help='The number of the encoding reserved units that you want to be provisioned for this account for concurrent tasks (one unit equals one task).')

    with self.argument_context('ams account storage') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('storage_account', name_arg_type,
                   help='The name or resource ID of the secondary storage account to detach from the Azure Media Services account.',
                   validator=validate_storage_account_id)

    with self.argument_context('ams account storage sync-storage-keys') as c:
        c.argument('id', required=True)

    with self.argument_context('ams account sp') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('sp_name', name_arg_type,
                   help="The app name or app URI to associate the RBAC with. If not present, a default name like '{amsaccountname}-access-sp' will be generated.")
        c.argument('sp_password', password_arg_type,
                   help="The password used to log in. Also known as 'Client Secret'. If not present, a random secret will be generated.")
        c.argument('role', help='The role of the service principal.', completer=get_role_definition_name_completion_list)
        c.argument('xml', action='store_true', help='Enables xml output format.')
        c.argument('years', help='Number of years for which the secret will be valid. Default: 1 year.', type=int, default=None)

    with self.argument_context('ams transform') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('transform_name', name_arg_type, id_part='child_name_1',
                   help='The name of the transform.')
        c.argument('preset', help='Preset that describes the operations that will be used to modify, transcode, or extract insights from the source file to generate the transform output. Allowed values: {}. In addition to the allowed values, you can also pass a path to a custom Standard Encoder preset JSON file. See https://docs.microsoft.com/rest/api/media/transforms/createorupdate#standardencoderpreset for further details on the settings to use to build a custom preset.'
                   .format(", ".join(get_presets_definition_name_completion_list())))
        c.argument('insights_to_extract', arg_group='Video Analyzer', arg_type=get_enum_type(InsightsType), help='The type of insights to be extracted. If not set then the type will be selected based on the content type. If the content is audio only then only audio insights will be extracted and if it is video only video insights will be extracted.')
        c.argument('audio_language', arg_group='Audio/Video Analyzer', help='The language for the audio payload in the input using the BCP-47 format of \"language tag-region\" (e.g: en-US). If not specified, automatic language detection would be employed. This feature currently supports English, Chinese, French, German, Italian, Japanese, Spanish, Russian, and Portuguese. The automatic detection works best with audio recordings with clearly discernable speech. If automatic detection fails to find the language, transcription would fallback to English. Allowed values: {}.'
                   .format(", ".join(get_allowed_languages_for_preset_completion_list())))
        c.argument('relative_priority', arg_type=get_enum_type(Priority), help='Sets the relative priority of the transform outputs within a transform. This sets the priority that the service uses for processing TransformOutputs. The default priority is Normal.')
        c.argument('on_error', arg_type=get_enum_type(OnErrorType), help="A Transform can define more than one output. This property defines what the service should do when one output fails - either continue to produce other outputs, or, stop the other outputs. The overall Job state will not reflect failures of outputs that are specified with 'ContinueJob'. The default is 'StopProcessingJob'.")
        c.argument('description', help='The description of the transform.')

    with self.argument_context('ams transform output remove') as c:
        c.argument('output_index', help='The element index of the output to remove.',
                   type=int, default=None)

    with self.argument_context('ams transform list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams asset') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('asset_name', name_arg_type, id_part='child_name_1',
                   help='The name of the asset.')

    with self.argument_context('ams asset list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams asset create') as c:
        c.argument('alternate_id', help='The alternate id of the asset.')
        c.argument('description', help='The asset description.')
        c.argument('asset_name', name_arg_type, help='The name of the asset.')
        c.argument('storage_account', help='The name of the storage account.')
        c.argument('container', help='The name of the asset blob container.')

    with self.argument_context('ams asset update') as c:
        c.argument('alternate_id', help='The alternate id of the asset.')
        c.argument('description', help='The asset description.')

    with self.argument_context('ams asset get-sas-urls') as c:
        c.argument('permissions', arg_type=get_enum_type(AssetContainerPermission),
                   help='The permissions to set on the SAS URL.')
        c.argument('expiry_time', expiry_arg_type, help="Specifies the UTC datetime (Y-m-d'T'H:M:S'Z') at which the SAS becomes invalid.")

    with self.argument_context('ams asset-filter') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('asset_name', help='The name of the asset.', id_part='child_name_1')
        c.argument('filter_name', name_arg_type, id_part='child_name_2', help='The name of the asset filter.')
        c.argument('start_timestamp', arg_group='Presentation Time Range',
                   help='Applies to Video on Demand (VoD) or Live Streaming. This is a long value that represents an absolute start point of the stream. The value gets rounded to the closest next GOP start. The unit is the timescale, so a startTimestamp of 150000000 would be for 15 seconds. Use startTimestamp and endTimestampp to trim the fragments that will be in the playlist (manifest). For example, startTimestamp=40000000 and endTimestamp=100000000 using the default timescale will generate a playlist that contains fragments from between 4 seconds and 10 seconds of the VoD presentation. If a fragment straddles the boundary, the entire fragment will be included in the manifest.')
        c.argument('end_timestamp', arg_group='Presentation Time Range',
                   help='Applies to Video on Demand (VoD).For the Live Streaming presentation, it is silently ignored and applied when the presentation ends and the stream becomes VoD.This is a long value that represents an absolute end point of the presentation, rounded to the closest next GOP start. The unit is the timescale, so an endTimestamp of 1800000000 would be for 3 minutes.Use startTimestamp and endTimestamp to trim the fragments that will be in the playlist (manifest).For example, startTimestamp=40000000 and endTimestamp=100000000 using the default timescale will generate a playlist that contains fragments from between 4 seconds and 10 seconds of the VoD presentation. If a fragment straddles the boundary, the entire fragment will be included in the manifest.')
        c.argument('presentation_window_duration', arg_group='Presentation Time Range',
                   help='Applies to Live Streaming only.Use presentationWindowDuration to apply a sliding window of fragments to include in a playlist.The unit for this property is timescale (see below).For example, set presentationWindowDuration=1200000000 to apply a two-minute sliding window. Media within 2 minutes of the live edge will be included in the playlist. If a fragment straddles the boundary, the entire fragment will be included in the playlist. The minimum presentation window duration is 60 seconds.')
        c.argument('live_backoff_duration', arg_group='Presentation Time Range',
                   help='Applies to Live Streaming only. This value defines the latest live position that a client can seek to. Using this property, you can delay live playback position and create a server-side buffer for players. The unit for this property is timescale (see below). The maximum live back off duration is 300 seconds (3000000000). For example, a value of 2000000000 means that the latest available content is 20 seconds delayed from the real live edge.')
        c.argument('timescale', arg_group='Presentation Time Range',
                   help='Applies to all timestamps and durations in a Presentation Time Range, specified as the number of increments in one second.Default is 10000000 - ten million increments in one second, where each increment would be 100 nanoseconds long. For example, if you want to set a startTimestamp at 30 seconds, you would use a value of 300000000 when using the default timescale.')
        c.argument('force_end_timestamp', arg_group='Presentation Time Range', arg_type=get_three_state_flag(),
                   help='Applies to Live Streaming only. Indicates whether the endTimestamp property must be present. If true, endTimestamp must be specified or a bad request code is returned. Allowed values: false, true.')
        c.argument('bitrate', help='The first quality bitrate.', deprecate_info=c.deprecate(target='--bitrate', redirect='--first-quality', hide=True))
        c.argument('first_quality', help='The first quality (lowest) bitrate to include in the manifest.')
        c.argument('tracks', help='The JSON representing the track selections. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/assetfilters/assetfilters_createorupdate#filtertrackselection')

    with self.argument_context('ams asset-filter list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams job') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('transform_name', transform_name_arg_type, id_part='child_name_1',
                   help='The name of the transform.')
        c.argument('job_name', name_arg_type, id_part='child_name_2',
                   help='The name of the job.')
        c.argument('description', help='The job description.')
        c.argument('priority', arg_type=get_enum_type(Priority),
                   help='The priority with which the job should be processed.')

    with self.argument_context('ams job list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams job create') as c:
        c.argument('correlation_data', arg_type=correlation_data_type)
        c.argument('input_asset_name',
                   arg_group='Asset Job Input',
                   help='The name of the input asset.')
        c.argument('output_assets', arg_type=output_assets_type)
        c.argument('base_uri',
                   arg_group='Http Job Input',
                   help='Base uri for http job input. It will be concatenated with provided file names. If no base uri is given, then the provided file list is assumed to be fully qualified uris.')
        c.argument('files',
                   nargs='+',
                   help='Space-separated list of files. It can be used to tell the service to only use the files specified from the input asset.')
        c.argument('label', help="A label that is assigned to a Job Input that is used to satisfy a reference used in the Transform. For example, a Transform can be authored to take an image file with the label 'xyz' and apply it as an overlay onto the input video before it is encoded. When submitting a Job, exactly one of the JobInputs should be the image file, and it should have the label 'xyz'.")
        c.argument('correlation_data', arg_type=correlation_data_type)

    with self.argument_context('ams job cancel') as c:
        c.argument('delete', action='store_true', help='Delete the job being cancelled.')

    with self.argument_context('ams content-key-policy') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('content_key_policy_name', name_arg_type, id_part='child_name_1',
                   help='The content key policy name.')
        c.argument('description', help='The content key policy description.')
        c.argument('clear_key_configuration',
                   action='store_true',
                   arg_group='Clear Key Configuration (AES Encryption)',
                   help='Use Clear Key configuration, a.k.a AES encryption. It\'s intended for non-DRM keys.')
        c.argument('open_restriction',
                   action='store_true',
                   arg_group='Open Restriction',
                   help='Use open restriction. License or key will be delivered on every request. Not recommended for production environments.')
        c.argument('policy_option_name', help='The content key policy option name.')
        c.argument('policy_option_id', help='The content key policy option identifier. This value can be obtained from "policyOptionId" property by running a show operation on a content key policy resource.')
        c.argument('issuer', arg_group='Token Restriction', help='The token issuer.')
        c.argument('audience', arg_group='Token Restriction', help='The audience for the token.')
        c.argument('token_key', arg_group='Token Restriction', help='Either a string (for symmetric key) or a filepath to a certificate (x509) or public key (rsa). Must be used in conjunction with --token-key-type.')
        c.argument('token_key_type', arg_group='Token Restriction', help='The type of the token key to be used for the primary verification key. Allowed values: {}'.format(", ".join(get_token_completion_list())))
        c.argument('add_alt_token_key', arg_group='Token Restriction', help='Creates an alternate token key with either a string (for symmetric key) or a filepath to a certificate (x509) or public key (rsa). Must be used in conjunction with --add-alt-token-key-type.')
        c.argument('add_alt_token_key_type', arg_group='Token Restriction', help='The type of the token key to be used for the alternate verification key. Allowed values: {}'.format(", ".join(get_token_completion_list())))
        c.argument('alt_symmetric_token_keys', nargs='+', arg_group='Token Restriction', help='Space-separated list of alternate symmetric token keys.')
        c.argument('alt_rsa_token_keys', nargs='+', arg_group='Token Restriction', help='Space-separated list of alternate rsa token keys.')
        c.argument('alt_x509_token_keys', nargs='+', arg_group='Token Restriction', help='Space-separated list of alternate x509 certificate token keys.')
        c.argument('token_claims', arg_group='Token Restriction', arg_type=token_claim_type)
        c.argument('token_type', arg_group='Token Restriction',
                   help='The type of token. Allowed values: {}.'.format(", ".join(get_token_type_completion_list())))
        c.argument('open_id_connect_discovery_document', arg_group='Token Restriction', help='The OpenID connect discovery document.')
        c.argument('widevine_template', arg_group='Widevine Configuration', help='JSON Widevine license template. Use @{file} to load from a file.')
        c.argument('ask', arg_group='FairPlay Configuration', help='The key that must be used as FairPlay Application Secret Key, which is a 32 character hex string.')
        c.argument('fair_play_pfx_password', arg_group='FairPlay Configuration', help='The password encrypting FairPlay certificate in PKCS 12 (pfx) format.')
        c.argument('fair_play_pfx', arg_group='FairPlay Configuration', help='The filepath to a FairPlay certificate file in PKCS 12 (pfx) format (including private key).')
        c.argument('rental_and_lease_key_type', arg_group='FairPlay Configuration', help='The rental and lease key type. Available values: {}.'.format(", ".join(get_fairplay_rentalandlease_completion_list())))
        c.argument('rental_duration', arg_group='FairPlay Configuration', help='The rental duration. Must be greater than or equal to 0.')
        c.argument('play_ready_template', arg_group='PlayReady Configuration', help='JSON PlayReady license template. Use @{file} to load from a file.')

    with self.argument_context('ams content-key-policy list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams content-key-policy show') as c:
        c.argument('with_secrets',
                   action='store_true',
                   help='Include secret values of the content key policy.')

    with self.argument_context('ams streaming-locator') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('default_content_key_policy_name', default_policy_name_arg_type)
        c.argument('streaming_locator_name', name_arg_type, id_part='child_name_1',
                   help='The name of the streaming locator.')
        c.argument('asset_name',
                   help='The name of the asset used by the streaming locator.')
        c.argument('streaming_policy_name',
                   help='The name of the streaming policy used by the streaming locator. You can either create one with `az ams streaming policy create` or use any of the predefined policies: {}'.format(", ".join(get_default_streaming_policies_completion_list())))
        c.argument('start_time', type=datetime_format,
                   help="The ISO 8601 DateTime start time (Y-m-d'T'H:M:S'Z') of the streaming locator.")
        c.argument('end_time', type=datetime_format,
                   help="The ISO 8601 DateTime end time (Y-m-d'T'H:M:S'Z') of the streaming locator.")
        c.argument('streaming_locator_id', help='The identifier of the streaming locator.')
        c.argument('alternative_media_id', help='An alternative media identifier associated with the streaming locator.')
        c.argument('content_keys', help='JSON string with the content keys to be used by the streaming locator. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streaminglocators/streaminglocators_create#streaminglocatorcontentkey')
        c.argument('filters', nargs='+', help='A space-separated list of asset filter names and/or account filter names.')

    with self.argument_context('ams streaming-locator list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams streaming-policy') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('streaming_policy_name', name_arg_type, id_part='child_name_1', help='The name of the streaming policy.')
        c.argument('default_content_key_policy_name', help='Default Content Key used by current streaming policy.')
        c.argument('no_encryption_protocols', nargs='+', help='Space-separated list of enabled protocols for NoEncryption. Allowed values: {}.'.format(", ".join(get_protocols_completion_list())))
        c.argument('envelope_protocols', nargs='+', arg_group='Envelope Encryption', help='Space-separated list of enabled protocols for Envelope Encryption. Allowed values: {}.'.format(", ".join(get_protocols_completion_list())))
        c.argument('envelope_clear_tracks', arg_group='Envelope Encryption', help='The JSON representing which tracks should not be encrypted. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streamingpolicies/create#trackselection')
        c.argument('envelope_key_to_track_mappings', arg_group='Envelope Encryption', help='The JSON representing a list of StreamingPolicyContentKey. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streamingpolicies/create#streamingpolicycontentkey')
        c.argument('envelope_default_key_label', arg_group='Envelope Encryption', help='Label used to specify Content Key when creating a streaming locator.')
        c.argument('envelope_default_key_policy_name', arg_group='Envelope Encryption', help='Policy used by Default Key.')
        c.argument('envelope_template', arg_group='Envelope Encryption', help='The KeyAcquistionUrlTemplate is used to point to user specified service to delivery content keys.')
        c.argument('cenc_protocols', nargs='+', arg_group='Common Encryption CENC', help='Space-separated list of enabled protocols for Common Encryption CENC. Allowed values: {}.'.format(", ".join(get_protocols_completion_list())))
        c.argument('cenc_default_key_label', arg_group='Common Encryption CENC', help='Label to specify Default Content Key for an encryption scheme.')
        c.argument('cenc_default_key_policy_name', arg_group='Common Encryption CENC', help='Policy used by Default Content Key.')
        c.argument('cenc_clear_tracks', arg_group='Common Encryption CENC', help='The JSON representing which tracks should not be encrypted. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streamingpolicies/create#trackselection')
        c.argument('cenc_key_to_track_mappings', arg_group='Common Encryption CENC', help='The JSON representing a list of StreamingPolicyContentKey. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streamingpolicies/create#streamingpolicycontentkey')
        c.argument('cenc_play_ready_attributes', arg_group='Common Encryption CENC', help='Custom attributes for PlayReady.')
        c.argument('cenc_widevine_template', arg_group='Common Encryption CENC', help='The custom license acquisition URL template for a customer service to deliver keys to end users. Not needed when using Azure Media Services for issuing keys.')
        c.argument('cenc_play_ready_template', arg_group='Common Encryption CENC', help='The custom license acquisition URL template for a customer service to deliver keys to end users. Not needed when using Azure Media Services for issuing keys.')
        c.argument('cenc_disable_widevine', arg_group='Common Encryption CENC', arg_type=get_three_state_flag(), help='If specified, no Widevine cenc DRM will be configured. If --cenc-disable-widevine is set, --cenc-disable-play-ready cannot also be set.')
        c.argument('cenc_disable_play_ready', arg_group='Common Encryption CENC', arg_type=get_three_state_flag(), help='If specified, no PlayReady cenc DRM will be configured. If --cenc-disable-play-ready is set, --cenc-disable-widevine cannot also be set.')
        c.argument('cbcs_protocols', nargs='+', arg_group='Common Encryption CBCS', help='Space-separated list of enabled protocols for Common Encryption CBCS. Allowed values: {}.'.format(", ".join(get_protocols_completion_list())))
        c.argument('cbcs_default_key_label', arg_group='Common Encryption CBCS', help='Label to specify Default Content Key for an encryption scheme.')
        c.argument('cbcs_default_key_policy_name', arg_group='Common Encryption CBCS', help='Policy used by Default Content Key.')
        c.argument('cbcs_clear_tracks', arg_group='Common Encryption CBCS', help='The JSON representing which tracks should not be encrypted. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streamingpolicies/create#trackselection')
        c.argument('cbcs_key_to_track_mappings', arg_group='Common Encryption CBCS', help='The JSON representing a list of StreamingPolicyContentKey. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/streamingpolicies/create#streamingpolicycontentkey')
        c.argument('cbcs_play_ready_attributes', arg_group='Common Encryption CBCS', help='Custom attributes for PlayReady.', deprecate_info=c.deprecate(hide=True))
        c.argument('cbcs_play_ready_template', arg_group='Common Encryption CBCS', help='The custom license acquisition URL template for a customer service to deliver keys to end users. Not needed when using Azure Media Services for issuing keys.', deprecate_info=c.deprecate(hide=True))
        c.argument('cbcs_widevine_template', arg_group='Common Encryption CBCS', help='The custom license acquisition URL template for a customer service to deliver keys to end users. Not needed when using Azure Media Services for issuing keys.', deprecate_info=c.deprecate(hide=True))
        c.argument('cbcs_fair_play_template', arg_group='Common Encryption CBCS', help='The custom license acquisition URL template for a customer service to deliver keys to end users. Not needed when using Azure Media Services for issuing keys.')
        c.argument('cbcs_fair_play_allow_persistent_license', arg_group='Common Encryption CBCS', arg_type=get_three_state_flag(), help='Allows the license to be persistent or not.')

    with self.argument_context('ams streaming-policy list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams streaming-endpoint') as c:
        c.argument('streaming_endpoint_name', name_arg_type, id_part='child_name_1',
                   help='The name of the streaming endpoint.')
        c.argument('account_name', account_name_arg_type)
        c.argument('tags', arg_type=tags_type)
        c.argument('description', help='The streaming endpoint description.')
        c.argument('scale_units', help='The number of scale units for Premium StreamingEndpoints. For Standard StreamingEndpoints, set this value to 0. Use the Scale operation to adjust this value for Premium StreamingEndpoints.')
        c.argument('availability_set_name', help='The name of the AvailabilitySet used with this StreamingEndpoint for high availability streaming. This value can only be set at creation time.')
        c.argument('max_cache_age', help='Max cache age.')
        c.argument('custom_host_names', nargs='+', help='Space-separated list of custom host names for the streaming endpoint. Use "" to clear existing list.')
        c.argument('cdn_provider', arg_group='CDN Support', help='The CDN provider name. Allowed values: {}.'.format(", ".join(get_cdn_provider_completion_list())))
        c.argument('cdn_profile', arg_group='CDN Support', help='The CDN profile name.')
        c.argument('client_access_policy', arg_group='Cross Site Access Policies',
                   help='The XML representing the clientaccesspolicy data used by Microsoft Silverlight and Adobe Flash. Use @{file} to load from a file. For further information about the XML structure please refer to documentation on https://docs.microsoft.com/rest/api/media/operations/crosssiteaccesspolicies')
        c.argument('cross_domain_policy', arg_group='Cross Site Access Policies',
                   help='The XML representing the crossdomain data used by Silverlight. Use @{file} to load from a file. For further information about the XML structure please refer to documentation on https://docs.microsoft.com/rest/api/media/operations/crosssiteaccesspolicies')
        c.argument('auto_start', action='store_true', help='The flag indicates if the resource should be automatically started on creation.')
        c.argument('ips', nargs='+', arg_group='Access Control Support', help='Space-separated IP addresses for access control. Allowed IP addresses can be specified as either a single IP address (e.g. "10.0.0.1") or as an IP range using an IP address and a CIDR subnet mask (e.g. "10.0.0.1/22"). Use "" to clear existing list. If no IP addresses are specified any IP address will be allowed.')
        c.argument('disable_cdn', arg_group='CDN Support', action='store_true', help='Use this flag to disable CDN for the streaming endpoint.')

    with self.argument_context('ams streaming-endpoint list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams streaming-endpoint scale') as c:
        c.argument('scale_unit', options_list=['--scale-units'], help='The number of scale units for Premium StreamingEndpoints.')

    with self.argument_context('ams streaming-endpoint akamai') as c:
        c.argument('identifier', help='The identifier for the authentication key. This is the nonce provided by Akamai.')
        c.argument('base64_key', help='Base64-encoded authentication key that will be used by the CDN. The authentication key provided by Akamai is an ASCII encoded string, and must be converted to bytes and then base64 encoded.')
        c.argument('expiration', type=datetime_format,
                   help='The ISO 8601 DateTime value that specifies when the Akamai authentication expires.')

    with self.argument_context('ams streaming-endpoint list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams live-event') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('live_event_name', name_arg_type, id_part='child_name_1',
                   help='The name of the live event.')
        c.argument('streaming_protocol', arg_type=get_enum_type(LiveEventInputProtocol),
                   arg_group='Input', help='The streaming protocol for the live event. This value is specified at creation time and cannot be updated.')
        c.argument('auto_start', action='store_true', help='The flag indicates if the resource should be automatically started on creation.')
        c.argument('encoding_type', arg_group='Encoding', help='The encoding type for live event. This value is specified at creation time and cannot be updated. Allowed values: {}.'.format(", ".join(get_encoding_types_list())))
        c.argument('preset_name', arg_group='Encoding', help='The encoding preset name. This value is specified at creation time and cannot be updated.')
        c.argument('tags', arg_type=tags_type)
        c.argument('key_frame_interval_duration', key_frame_interval_duration_arg_type, arg_group='Input', validator=validate_key_frame_interval_duration,
                   help='ISO 8601 timespan duration of the key frame interval duration in seconds. The value should be an interger in the range of 1 (PT1S or 00:00:01) to 30 (PT30S or 00:00:30) seconds.')
        c.argument('access_token', arg_group='Input', help='A unique identifier for a stream. This can be specified at creation time but cannot be updated. If omitted, the service will generate a unique value.')
        c.argument('description', help='The live event description.')
        c.argument('ips', nargs='+', arg_group='Input', help='Space-separated IP addresses for access control. Allowed IP addresses can be specified as either a single IP address (e.g. "10.0.0.1") or as an IP range using an IP address and a CIDR subnet mask (e.g. "10.0.0.1/22"). Use "" to clear existing list. Use "AllowAll" to allow all IP addresses. Allowing all IPs is not recommended for production environments.')
        c.argument('preview_ips', nargs='+', arg_group='Preview', help='Space-separated IP addresses for access control. Allowed IP addresses can be specified as either a single IP address (e.g. "10.0.0.1") or as an IP range using an IP address and a CIDR subnet mask (e.g. "10.0.0.1/22"). Use "" to clear existing list. Use "AllowAll" to allow all IP addresses. Allowing all IPs is not recommended for production environments.')
        c.argument('preview_locator', arg_group='Preview', help='The identifier of the preview locator in Guid format. Specifying this at creation time allows the caller to know the preview locator url before the event is created. If omitted, the service will generate a random identifier. This value cannot be updated once the live event is created.')
        c.argument('streaming_policy_name', arg_group='Preview', help='The name of streaming policy used for the live event preview. This can be specified at creation time but cannot be updated.')
        c.argument('alternative_media_id', arg_group='Preview', help='An Alternative Media Identifier associated with the StreamingLocator created for the preview. This value is specified at creation time and cannot be updated. The identifier can be used in the CustomLicenseAcquisitionUrlTemplate or the CustomKeyAcquisitionUrlTemplate of the StreamingPolicy specified in the StreamingPolicyName field.')
        c.argument('vanity_url', arg_type=get_three_state_flag(), help='Specifies whether to use a vanity url with the Live Event. This value is specified at creation time and cannot be updated.')
        c.argument('client_access_policy', arg_group='Cross Site Access Policies', help='Filepath to the clientaccesspolicy.xml used by Microsoft Silverlight and Adobe Flash. Use @{file} to load from a file.')
        c.argument('cross_domain_policy', arg_group='Cross Site Access Policies', help='Filepath to the crossdomain.xml used by Microsoft Silverlight and Adobe Flash. Use @{file} to load from a file.')
        c.argument('stream_options', nargs='+', arg_type=get_enum_type(StreamOptionsFlag), help='The options to use for the LiveEvent. This value is specified at creation time and cannot be updated.')
        c.argument('remove_outputs_on_stop', action='store_true', help='Remove live outputs on stop.')

    with self.argument_context('ams live-event list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams live-output') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('live_event_name', id_part='child_name_1',
                   help='The name of the live event.')
        c.argument('live_output_name', name_arg_type, id_part='child_name_2',
                   help='The name of the live output.')

    with self.argument_context('ams live-output list') as c:
        c.argument('account_name', id_part=None)

    with self.argument_context('ams live-output create') as c:
        c.argument('asset_name', help='The name of the asset.')
        c.argument('archive_window_length', archive_window_length_arg_type, validator=validate_archive_window_length,
                   help="ISO 8601 timespan duration of the archive window length. This is the duration that customer want to retain the recorded content. Minimum window is 5 minutes (PT5M or 00:05:00). Maximum window is 25 hours (PT25H or 25:00:00). For example, to retain the output for 10 minutes, use PT10M or 00:10:00")
        c.argument('manifest_name', help='The manifest file name. If not provided, the service will generate one automatically.')
        c.argument('description', help='The live output description.')
        c.argument('fragments_per_ts_segment', help='The number of fragments per HLS segment.')
        c.argument('output_snap_time', help='The output snapshot time.')

    with self.argument_context('ams account-filter') as c:
        c.argument('account_name', account_name_arg_type)
        c.argument('filter_name', name_arg_type, id_part='child_name_1', help='The name of the account filter.')
        c.argument('start_timestamp', arg_group='Presentation Time Range',
                   help='Applies to Video on Demand (VoD) or Live Streaming. This is a long value that represents an absolute start point of the stream. The value gets rounded to the closest next GOP start. The unit is the timescale, so a startTimestamp of 150000000 would be for 15 seconds. Use startTimestamp and endTimestampp to trim the fragments that will be in the playlist (manifest). For example, startTimestamp=40000000 and endTimestamp=100000000 using the default timescale will generate a playlist that contains fragments from between 4 seconds and 10 seconds of the VoD presentation. If a fragment straddles the boundary, the entire fragment will be included in the manifest.')
        c.argument('end_timestamp', arg_group='Presentation Time Range',
                   help='Applies to Video on Demand (VoD). For the Live Streaming presentation, it is silently ignored and applied when the presentation ends and the stream becomes VoD. This is a long value that represents an absolute end point of the presentation, rounded to the closest next GOP start. The unit is the timescale, so an endTimestamp of 1800000000 would be for 3 minutes. Use startTimestamp and endTimestamp to trim the fragments that will be in the playlist (manifest). For example, startTimestamp=40000000 and endTimestamp=100000000 using the default timescale will generate a playlist that contains fragments from between 4 seconds and 10 seconds of the VoD presentation. If a fragment straddles the boundary, the entire fragment will be included in the manifest.')
        c.argument('presentation_window_duration', arg_group='Presentation Time Range',
                   help='Applies to Live Streaming only. Use presentationWindowDuration to apply a sliding window of fragments to include in a playlist. The unit for this property is timescale (see below). For example, set presentationWindowDuration=1200000000 to apply a two-minute sliding window. Media within 2 minutes of the live edge will be included in the playlist. If a fragment straddles the boundary, the entire fragment will be included in the playlist. The minimum presentation window duration is 60 seconds.')
        c.argument('live_backoff_duration', arg_group='Presentation Time Range',
                   help='Applies to Live Streaming only. This value defines the latest live position that a client can seek to. Using this property, you can delay live playback position and create a server-side buffer for players. The unit for this property is timescale (see below). The maximum live back off duration is 300 seconds (3000000000). For example, a value of 2000000000 means that the latest available content is 20 seconds delayed from the real live edge.')
        c.argument('timescale', arg_group='Presentation Time Range',
                   help='Applies to all timestamps and durations in a Presentation Time Range, specified as the number of increments in one second. Default is 10000000 - ten million increments in one second, where each increment would be 100 nanoseconds long. For example, if you want to set a startTimestamp at 30 seconds, you would use a value of 300000000 when using the default timescale.')
        c.argument('force_end_timestamp', arg_group='Presentation Time Range', arg_type=get_three_state_flag(),
                   help='Applies to Live Streaming only. Indicates whether the endTimestamp property must be present. If true, endTimestamp must be specified or a bad request code is returned. Allowed values: false, true.')
        c.argument('bitrate', help='The first quality bitrate.', deprecate_info=c.deprecate(target='--bitrate', redirect='--first-quality', hide=True))
        c.argument('first_quality', help='The first quality (lowest) bitrate to include in the manifest.')
        c.argument('tracks', help='The JSON representing the track selections. Use @{file} to load from a file. For further information about the JSON structure please refer to swagger documentation on https://docs.microsoft.com/rest/api/media/accountfilters/createorupdate#filtertrackselection')

    with self.argument_context('ams account-filter list') as c:
        c.argument('account_name', id_part=None)
示例#36
0
def load_arguments(self, _):
    batch_name_type = CLIArgumentType(
        help='Name of the Batch account.',
        options_list=('--account-name',),
        completer=get_resource_name_completion_list('Microsoft.Batch/batchAccounts'),
        id_part=None)

    with self.argument_context('batch') as c:
        c.argument('resource_group_name', resource_group_name_type, help='Name of the resource group', completer=None, validator=None, required=True)

    with self.argument_context('batch account') as c:
        c.argument('account_name', batch_name_type, options_list=('--name', '-n'))

    with self.argument_context('batch account show') as c:
        c.argument('resource_group_name', resource_group_name_type, help='Name of the resource group. If not specified will display currently set account.', required=False)
        c.argument('account_name', batch_name_type, options_list=('--name', '-n'), help='Name of the batch account to show. If not specified will display currently set account.', required=False)

    with self.argument_context('batch account list') as c:
        c.argument('resource_group_name', resource_group_name_type, help='Name of the resource group', required=False)

    with self.argument_context('batch account create') as c:
        c.argument('location', get_location_type(self.cli_ctx), help='The region in which to create the account.')
        c.argument('tags', tags_type, help="Space-separated tags in 'key[=value]' format.")
        c.argument('storage_account', help='The storage account name or resource ID to be used for auto storage.', validator=storage_account_id)
        c.argument('keyvault', help='The KeyVault name or resource ID to be used for an account with a pool allocation mode of \'User Subscription\'.', validator=keyvault_id)
        c.ignore('keyvault_url')

    with self.argument_context('batch account set') as c:
        c.argument('tags', tags_type)
        c.argument('storage_account', help='The storage account name or resource ID to be used for auto storage.', validator=storage_account_id)

    with self.argument_context('batch account keys renew') as c:
        c.argument('key_name', arg_type=get_enum_type(AccountKeyType))

    with self.argument_context('batch account login') as c:
        c.argument('shared_key_auth', action='store_true', help='Using Shared Key authentication, if not specified, it will use Azure Active Directory authentication.')
        c.argument('show', action='store_true', help='Display the credential information for the Batch account.')

    with self.argument_context('batch application set') as c:
        c.argument('application_id', options_list=('--application-id',), help="The ID of the application.")
        c.argument('allow_updates', options_list=('--allow-updates',), help="Specify to indicate whether packages within the application may be overwritten using the same version string. Specify either 'true' or 'false' to update the property.")

    with self.argument_context('batch application create') as c:
        c.argument('allow_updates', options_list=('--allow-updates',), action="store_true", help="Specify to indicate whether packages within the application may be overwritten using the same version string. True if flag present.")

    with self.argument_context('batch application package create') as c:
        c.argument('package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter())
        c.argument('application_id', options_list=('--application-id',), help="The ID of the application.")
        c.argument('version', options_list=('--version',), help="The version of the application.")

    with self.argument_context('batch location quotas show') as c:
        c.argument('location_name', get_location_type(self.cli_ctx), help='The region from which to display the Batch service quotas.')

    for command in ['list', 'show', 'create', 'set', 'delete', 'package']:
        with self.argument_context('batch application {}'.format(command)) as c:
            c.argument('account_name', batch_name_type, options_list=('--name', '-n'), validator=application_enabled)

    # TODO: Refactor so the help text can be extracted automatically
    with self.argument_context('batch pool resize') as c:
        c.argument('if_modified_since', help='The operation will be performed only if the resource has been modified since the specified timestamp.', type=datetime_format, arg_group='Pre-condition and Query')
        c.argument('if_unmodified_since', help='The operation will not be performed only if the resource has been modified since the specified timestamp.', type=datetime_format, arg_group='Pre-condition and Query')
        c.argument('if_match', help='The operation will be performed only if the resource\'s current ETag exactly matches the specified value.', arg_group='Pre-condition and Query')
        c.argument('if_none_match', help='The operation will not be performed only if the resource\'s current ETag exactly matches the specified value.', arg_group='Pre-condition and Query')
        c.argument('pool_id', help='The ID of the pool.')
        c.argument('abort', action='store_true', help='Stop the pool resize operation.', validator=validate_pool_resize_parameters)
        c.argument('node_deallocation_option', options_list=('--node-deallocation-option',), help='When nodes may be removed from the pool, if the pool size is decreasing.', arg_type=get_enum_type(ComputeNodeDeallocationOption))

    # TODO: Refactor so the help text can be extracted automatically
    with self.argument_context('batch pool reset') as c:
        c.argument('json_file', type=file_type, help='The file containing pool update properties parameter specification in JSON(formatted to match REST API request body). If this parameter is specified, all \'Pool Update Properties Parameter Arguments\' are ignored.', validator=validate_json_file, completer=FilesCompleter())
        c.argument('pool_id', help='The ID of the pool to update.')
        c.argument('application_package_references', nargs='+', type=application_package_reference_format, arg_group='Pool')
        c.argument('certificate_references', nargs='+', type=certificate_reference_format, arg_group='Pool')
        c.argument('metadata', nargs='+', type=metadata_item_format, arg_group='Pool')
        c.argument('start_task_command_line', arg_group='Pool: Start Task',
                   help='The command line of the start task. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux.')
        c.argument('start_task_wait_for_success', action='store_true', arg_group='Pool: Start Task',
                   help='Whether the Batch service should wait for the start task to complete successfully (that is, to exit with exit code 0) before scheduling any tasks on the compute node. True if flag present, otherwise defaults to False.')
        c.argument('start_task_max_task_retry_count', arg_group='Pool: Start Task',
                   help='The maximum number of times the task may be retried.')
        c.argument('start_task_environment_settings', nargs='+', type=environment_setting_format, arg_group='Pool: Start Task',
                   help='A list of environment variable settings for the start task. Space-separated values in \'key=value\' format.')

    with self.argument_context('batch job list') as c:
        c.argument('filter', help=' An OData $filter clause.', arg_group='Pre-condition and Query')
        c.argument('select', help=' An OData $select clause.', arg_group='Pre-condition and Query')
        c.argument('expand', help=' An OData $expand clause.', arg_group='Pre-condition and Query')
        c.argument('job_schedule_id', help='The ID of the job schedule from which you want to get a list of jobs. If omitted, lists all jobs in the account.')

    for command in ['job create', 'job set', 'job reset', 'job-schedule create', 'job-schedule set', 'job-schedule reset']:
        with self.argument_context('batch {}'.format(command)) as c:
            c.argument('pool_id', options_list=('--pool-id',), help='The id of an existing pool. All the tasks of the job will run on the specified pool.')

    with self.argument_context('batch pool create') as c:
        c.argument('os_family', arg_type=get_enum_type(['2', '3', '4', '5']))
        c.argument('auto_scale_formula', help='A formula for the desired number of compute nodes in the pool. The formula is checked for validity before the pool is created. If the formula is not valid, the Batch service rejects the request with detailed error information. For more information about specifying this formula, see https://azure.microsoft.com/documentation/articles/batch-automatic-scaling/.')
        c.extra('image', completer=load_node_agent_skus, arg_group="Pool: Virtual Machine Configuration",
                help="OS image reference. This can be either 'publisher:offer:sku[:version]' format, or a fully qualified ARM image id of the form '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}'. If 'publisher:offer:sku[:version]' format, version is optional and if omitted latest will be used. Valid values can be retrieved via 'az batch pool node-agent-skus list'. For example: 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest'")

    with self.argument_context('batch certificate') as c:
        c.argument('thumbprint', help='The certificate thumbprint.')
        c.argument('password', help='The password to access the certificate\'s private key.')
        c.argument('certificate_file', type=file_type, help='The certificate file: cer file or pfx file.', validator=validate_cert_file, completer=FilesCompleter())
        c.argument('abort', action='store_true', help='Cancel the failed certificate deletion operation.')

    with self.argument_context('batch certificate show') as c:
        c.argument('thumbprint', help='The certificate thumbprint.', validator=validate_cert_settings)

    with self.argument_context('batch task create') as c:
        c.argument('json_file', type=file_type, help='The file containing the task(s) to create in JSON(formatted to match REST API request body). When submitting multiple tasks, accepts either an array of tasks or a TaskAddCollectionParamater. If this parameter is specified, all other parameters are ignored.', validator=validate_json_file, completer=FilesCompleter())
        c.argument('application_package_references', nargs='+', help='The space-separated list of IDs specifying the application packages to be installed. Space-separated application IDs with optional version in \'id[#version]\' format.', type=application_package_reference_format)
        c.argument('job_id', help='The ID of the job containing the task.')
        c.argument('task_id', help='The ID of the task.')
        c.argument('command_line', help='The command line of the task. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux.')
        c.argument('environment_settings', nargs='+', help='A list of environment variable settings for the task. Space-separated values in \'key=value\' format.', type=environment_setting_format)
        c.argument('resource_files', nargs='+', help='A list of files that the Batch service will download to the compute node before running the command line. Space-separated resource references in filename=blobsource format.', type=resource_file_format)

    for item in ['batch certificate delete', 'batch certificate create', 'batch pool resize', 'batch pool reset', 'batch job list', 'batch task create']:
        with self.argument_context(item) as c:
            c.extra('account_name', arg_group='Batch Account', validator=validate_client_parameters,
                    help='The Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT')
            c.extra('account_key', arg_group='Batch Account',
                    help='The Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY')
            c.extra('account_endpoint', arg_group='Batch Account',
                    help='Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT')
示例#37
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.')
示例#38
0
def load_arguments(self, _):    # pylint: disable=too-many-statements
    with self.argument_context('eventgrid') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('tags', arg_type=tags_type)
        c.argument('included_event_types', arg_type=included_event_types_type)
        c.argument('labels', arg_type=labels_type)
        c.argument('endpoint_type', arg_type=get_enum_type(['webhook', 'eventhub', 'storagequeue', 'hybridconnection', 'servicebusqueue'], default='webhook'))
        c.argument('source_resource_id', help="Fully qualified identifier of the source Azure resource.")
        c.argument('resource_id', deprecate_info=c.deprecate(redirect="--source-resource-id", expiration='2.1.0', hide=True), help="Fully qualified identifier of the Azure resource.")
        c.argument('endpoint', help="Endpoint where EventGrid should deliver events matching this event subscription. For webhook endpoint type, this should be the corresponding webhook URL. For other endpoint types, this should be the Azure resource identifier of the endpoint.")
        c.argument('event_subscription_name', help="Name of the event subscription.")
        c.argument('subject_begins_with', help="An optional string to filter events for an event subscription based on a prefix. Wildcard characters are not supported.")
        c.argument('subject_ends_with', help="An optional string to filter events for an event subscription based on a suffix. Wildcard characters are not supported.")
        c.argument('topic_type_name', help="Name of the topic type.")
        c.argument('is_subject_case_sensitive', arg_type=get_three_state_flag(), options_list=['--subject-case-sensitive'], help="Specify to indicate whether the subject fields should be compared in a case sensitive manner. True if flag present.", )
        c.argument('input_mapping_fields', arg_type=input_mapping_fields_type)
        c.argument('input_mapping_default_values', arg_type=input_mapping_default_values_type)
        c.argument('input_schema', arg_type=input_schema_type)
        c.argument('odata_query', arg_type=odata_query_type)
        c.argument('domain_name', arg_type=domain_name_type)
        c.argument('domain_topic_name', arg_type=domain_topic_name_type)

    with self.argument_context('eventgrid topic') as c:
        c.argument('topic_name', arg_type=name_type, help='Name of the topic.', id_part='name', completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))

    with self.argument_context('eventgrid topic key') as c:
        c.argument('topic_name', arg_type=name_type, help='Name of the topic', id_part=None, completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))

    with self.argument_context('eventgrid topic list') as c:
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid domain') as c:
        c.argument('domain_name', arg_type=domain_name_type, options_list=['--name', '-n'], id_part='name')

    with self.argument_context('eventgrid domain list') as c:
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid domain key') as c:
        c.argument('domain_name', arg_type=domain_name_type, options_list=['--name', '-n'], id_part=None)

    with self.argument_context('eventgrid domain topic') as c:
        c.argument('domain_name', arg_type=domain_name_type, id_part='name')
        c.argument('domain_topic_name', arg_type=domain_topic_name_type, options_list=['--name', '-n'], id_part='topics')

    with self.argument_context('eventgrid domain topic list') as c:
        c.argument('domain_name', arg_type=domain_name_type, id_part=None)
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid event-subscription') as c:
        c.argument('topic_name', deprecate_info=c.deprecate(expiration='2.1.0', hide=True), help='Name of Event Grid topic.', options_list=['--topic-name'], completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))
        c.argument('event_subscription_name', arg_type=name_type, help='Name of the event subscription.')
        c.argument('event_delivery_schema', arg_type=get_enum_type(['eventgridschema', 'custominputschema', 'cloudeventv01schema']), help='The schema in which events should be delivered for this event subscription. By default, events will be delivered in the same schema in which they are published (based on the corresponding topic\'s input schema).')
        c.argument('max_delivery_attempts', help="Maximum number of delivery attempts. Must be a number between 1 and 30.")
        c.argument('event_ttl', help="Event time to live (in minutes). Must be a number between 1 and 1440.")
        c.argument('deadletter_endpoint', help="The Azure resource ID of an Azure Storage blob container destination where EventGrid should deadletter undeliverable events for this event subscription.")
        c.argument('advanced_filter', action=EventSubscriptionAddFilter, nargs='+')
        c.argument('expiration_date', help="Date or datetime (in UTC, e.g. '2018-11-30T11:59:59+00:00' or '2018-11-30') after which the event subscription would expire. By default, there is no expiration for the event subscription.")

    with self.argument_context('eventgrid event-subscription create') as c:
        c.argument('resource_group_name', deprecate_info=c.deprecate(expiration='2.1.0', hide=True), arg_type=resource_group_name_type)

    with self.argument_context('eventgrid event-subscription delete') as c:
        c.argument('resource_group_name', deprecate_info=c.deprecate(expiration='2.1.0', hide=True), arg_type=resource_group_name_type)

    with self.argument_context('eventgrid event-subscription update') as c:
        c.argument('resource_group_name', deprecate_info=c.deprecate(expiration='2.1.0', hide=True), arg_type=resource_group_name_type)

    with self.argument_context('eventgrid event-subscription list') as c:
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid event-subscription show') as c:
        c.argument('resource_group_name', deprecate_info=c.deprecate(expiration='2.1.0', hide=True), arg_type=resource_group_name_type)
        c.argument('include_full_endpoint_url', arg_type=get_three_state_flag(), options_list=['--include-full-endpoint-url'], help="Specify to indicate whether the full endpoint URL should be returned. True if flag present.", )

    with self.argument_context('eventgrid topic-type') as c:
        c.argument('topic_type_name', arg_type=name_type, help="Name of the topic type.", completer=get_resource_name_completion_list('Microsoft.EventGrid/topictypes'))
示例#39
0
def load_arguments(self, _):

    with self.argument_context('logic workflow list') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('top',
                   help='The number of items to be included in the result.')
        c.argument(
            'filter',
            help=
            'The filter to apply on the operation. Options for filters include: State, Trigger, a'
            'nd ReferencedResourceId.')

    with self.argument_context('logic workflow show') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The workflow name.')

    with self.argument_context('logic workflow create') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The workflow name.')
        c.argument(
            'definition',
            type=validate_file_or_dict,
            help=
            'Path to a workflow defintion JSON file (see https://github.com/Azure/azure-cli-extensions/blob/main/src/logic/README.md for more info on this). '
            +
            'This JSON format should match what the logic app design tool exports',
            completer=FilesCompleter())
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('integration_account',
                   action=AddIntegrationAccount,
                   nargs='+',
                   help='The integration account.')
        c.argument('integration_service_environment',
                   action=AddIntegrationServiceEnvironment,
                   nargs='+',
                   help='The integration service environment.')
        c.argument('endpoints_configuration',
                   arg_type=CLIArgumentType(
                       options_list=['--endpoints-configuration'],
                       help='The endpoints configuration.'))
        c.argument(
            'access_control',
            arg_type=CLIArgumentType(
                options_list=['--access-control'],
                help='The access contr'
                'ol configuration controls access to this workflow. See https://github.com/Azure/azure-cli-extensions/blob/main/src/logic/README.md for more information'
            ))
        c.argument('state',
                   arg_type=get_enum_type([
                       'NotSpecified', 'Completed', 'Enabled', 'Disabled',
                       'Deleted', 'Sus'
                       'pended'
                   ]),
                   help='The state.')
        c.argument('tags', tags_type, help='The resource tags.')

    with self.argument_context('logic workflow update') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The workflow name.')
        c.argument('state',
                   arg_type=get_enum_type([
                       'NotSpecified', 'Completed', 'Enabled', 'Disabled',
                       'Deleted', 'Sus'
                       'pended'
                   ]),
                   help='The state.')
        c.argument(
            'definition',
            type=validate_file_or_dict,
            help=
            'Path to a workflow defintion JSON file (see https://github.com/Azure/azure-cli-extensions/blob/main/src/logic/README.md for more info on this). '
            +
            'This JSON format should match what the logic app design tool exports',
            completer=FilesCompleter())
        c.argument('tags', tags_type, help='The resource tags.')

    with self.argument_context('logic workflow delete') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The workflow name.')

    with self.argument_context('logic integration-account list') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('top',
                   help='The number of items to be included in the result.')

    with self.argument_context('logic integration-account show') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The integration account name.')

    with self.argument_context('logic integration-account create') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The integration account name.')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type, help='The resource tags.')
        c.argument('sku', type=str, help='The integration account sku.')
        c.argument(
            'integration_service_environment',
            arg_type=CLIArgumentType(
                options_list=['--integration-service-env'
                              'ironment'],
                help='The integration se'
                'rvice environment. See https://github.com/Azure/azure-cli-extensions/blob/main/src/logic/README.md For more information'
            ))
        c.argument('state',
                   arg_type=get_enum_type([
                       'NotSpecified', 'Completed', 'Enabled', 'Disabled',
                       'Deleted', 'Sus'
                       'pended'
                   ]),
                   help='The workflow state.')

    with self.argument_context('logic integration-account update') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The integration account name.')
        c.argument('tags', tags_type, help='The resource tags.')
        c.argument('sku', type=str, help='The integration account sku.')
        c.argument(
            'integration_service_environment',
            arg_type=CLIArgumentType(
                options_list=['--integration-service-env'
                              'ironment'],
                help='The integration se'
                'rvice environment. See https://github.com/Azure/azure-cli-extensions/blob/main/src/logic/README.md For more information'
            ))
        c.argument('state',
                   arg_type=get_enum_type([
                       'NotSpecified', 'Completed', 'Enabled', 'Disabled',
                       'Deleted', 'Sus'
                       'pended'
                   ]),
                   help='The workflow state.')

    with self.argument_context('logic integration-account delete') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The integration account name.')

    with self.argument_context('logic integration-account import') as c:
        c.argument('resource_group_name',
                   resource_group_name_type,
                   help='The resource group name.')
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='The integration account name.')
        c.argument('input_path',
                   type=validate_file_or_dict,
                   help='Path to a intergration-account JSON file',
                   completer=FilesCompleter())
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type, help='The resource tags.')
        c.argument('sku', type=str, help='The integration account sku.')
示例#40
0
def load_arguments(self, _):

    with self.argument_context('sql') as c:
        c.argument('location_name', arg_type=get_location_type(self.cli_ctx))
        c.argument('usage_name', options_list=['--usage', '-u'])

    with self.argument_context('sql db') as c:
        c.argument('server_name',
                   arg_type=server_param_type,
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')

        c.argument('database_name',
                   options_list=['--name', '-n'],
                   help='Name of the Azure SQL Database.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        c.argument('elastic_pool_name', options_list=['--elastic-pool'])
        c.argument('requested_service_objective_name', options_list=['--service-objective'])
        c.argument('max_size_bytes', options_list=['--max-size'],
                   type=SizeWithUnitConverter('B', result_type=int),
                   help='The max storage size of the database. Only the following'
                   ' sizes are supported (in addition to limitations being placed on'
                   ' each edition): 100MB, 500MB, 1GB, 5GB, 10GB, 20GB,'
                   ' 30GB, 150GB, 200GB, 500GB. If no unit is specified, defaults to bytes (B).')

        # Adjust help text.
        c.argument('edition',
                   options_list=['--edition'],
                   help='The edition of the database.')

        c.argument('zone_redundant',
                   options_list=['--zone-redundant', '-z'],
                   help='Specifies whether to enable zone redundancy for the database.',
                   arg_type=get_three_state_flag())

    with self.argument_context('sql db create') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.default)

    with self.argument_context('sql db copy') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.copy)

        c.argument('elastic_pool_name',
                   help='Name of the elastic pool to create the new database in.')

        c.argument('dest_name',
                   help='Name of the database that will be created as the copy destination.')

        c.argument('dest_resource_group_name',
                   options_list=['--dest-resource-group'],
                   help='Name of the resouce group to create the copy in.'
                   ' If unspecified, defaults to the origin resource group.')

        c.argument('dest_server_name',
                   options_list=['--dest-server'],
                   help='Name of the server to create the copy in.'
                   ' If unspecified, defaults to the origin server.')

        c.argument('requested_service_objective_name',
                   options_list=['--service-objective'],
                   help='Name of the service objective for the new database.')

    with self.argument_context('sql db rename') as c:
        c.argument('new_name',
                   help='The new name that the database will be renamed to.')

    with self.argument_context('sql db restore') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.point_in_time_restore)

        c.argument('dest_name',
                   help='Name of the database that will be created as the restore destination.')

        restore_point_arg_group = 'Restore Point'

        c.argument('restore_point_in_time',
                   options_list=['--time', '-t'],
                   arg_group=restore_point_arg_group,
                   help='The point in time of the source database that will be restored to create the'
                   ' new database. Must be greater than or equal to the source database\'s'
                   ' earliestRestoreDate value. Either --time or --deleted-time (or both) must be specified.')

        c.argument('source_database_deletion_date',
                   options_list=['--deleted-time'],
                   arg_group=restore_point_arg_group,
                   help='If specified, restore from a deleted database instead of from an existing database.'
                   ' Must match the deleted time of a deleted database in the same server.'
                   ' Either --time or --deleted-time (or both) must be specified.')

        c.argument('edition',
                   help='The edition for the new database.')
        c.argument('elastic_pool_name',
                   help='Name of the elastic pool to create the new database in.')
        c.argument('requested_service_objective_name',
                   help='Name of service objective for the new database.')

    with self.argument_context('sql db show') as c:
        # Service tier advisors and transparent data encryption are not included in the first batch
        # of GA commands.
        c.ignore('expand')

    with self.argument_context('sql db list') as c:
        c.argument('elastic_pool_name',
                   help='If specified, lists only the databases in this elastic pool')

    with self.argument_context('sql db list-editions') as c:
        c.argument('show_details',
                   options_list=['--show-details', '-d'],
                   help='List of additional details to include in output.',
                   nargs='+',
                   arg_type=get_enum_type(DatabaseCapabilitiesAdditionalDetails))

        search_arg_group = 'Search'

        # We could used get_enum_type here, but that will validate the inputs which means there
        # will be no way to query for new editions/service objectives that are made available after
        # this version of CLI is released.
        c.argument('edition',
                   arg_group=search_arg_group,
                   help='Edition to search for. If unspecified, all editions are shown.')
        c.argument('service_objective',
                   arg_group=search_arg_group,
                   help='Service objective to search for. If unspecified, all editions are shown.')

    with self.argument_context('sql db update') as c:
        c.argument('requested_service_objective_name',
                   help='The name of the new service objective. If this is a standalone db service'
                   ' objective and the db is currently in an elastic pool, then the db is removed from'
                   ' the pool.')
        c.argument('elastic_pool_name', help='The name of the elastic pool to move the database into.')
        c.argument('max_size_bytes', help='The new maximum size of the database expressed in bytes.')

    with self.argument_context('sql db export') as c:
        c.expand('parameters', ExportRequest)
        c.argument('administrator_login', options_list=['--admin-user', '-u'])
        c.argument('administrator_login_password', options_list=['--admin-password', '-p'])
        c.argument('authentication_type', options_list=['--auth-type', '-a'],
                   arg_type=get_enum_type(AuthenticationType))
        c.argument('storage_key_type', arg_type=get_enum_type(StorageKeyType))

    with self.argument_context('sql db import') as c:
        c.expand('parameters', ImportExtensionRequest)
        c.argument('administrator_login', options_list=['--admin-user', '-u'])
        c.argument('administrator_login_password', options_list=['--admin-password', '-p'])
        c.argument('authentication_type', options_list=['--auth-type', '-a'],
                   arg_type=get_enum_type(AuthenticationType))
        c.argument('storage_key_type', arg_type=get_enum_type(StorageKeyType))

        c.ignore('type')

        # The parameter name '--name' is used for 'database_name', so we need to give a different name
        # for the import extension 'name' parameter to avoid conflicts. This parameter is actually not
        # needed, but we still need to avoid this conflict.
        c.argument('name', options_list=['--not-name'], arg_type=ignore_type)

    with self.argument_context('sql db show-connection-string') as c:
        c.argument('client_provider',
                   options_list=['--client', '-c'],
                   help='Type of client connection provider.',
                   arg_type=get_enum_type(ClientType))

        auth_group = 'Authentication'

        c.argument('auth_type',
                   options_list=['--auth-type', '-a'],
                   arg_group=auth_group,
                   help='Type of authentication.',
                   arg_type=get_enum_type(ClientAuthenticationType))

    #####
    #           sql db op
    #####
    with self.argument_context('sql db op') as c:
        c.argument('database_name',
                   options_list=['--database', '-d'],
                   required=True,
                   help='Name of the Azure SQL Database.')

        c.argument('operation_id',
                   options_list=['--name', '-n'],
                   required=True,
                   help='The unique name of the operation to cancel.')

    #####
    #           sql db replica
    #####
    with self.argument_context('sql db replica create') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.online_secondary)

        c.argument('elastic_pool_name',
                   options_list=['--elastic-pool'],
                   help='Name of elastic pool to create the new replica in.')

        c.argument('requested_service_objective_name',
                   options_list=['--service-objective'],
                   help='Name of service objective for the new replica.')

        c.argument('partner_resource_group_name',
                   options_list=['--partner-resource-group'],
                   help='Name of the resource group to create the new replica in.'
                   ' If unspecified, defaults to the origin resource group.')

        c.argument('partner_server_name',
                   options_list=['--partner-server'],
                   help='Name of the server to create the new replica in.')

    with self.argument_context('sql db replica set-primary') as c:
        c.argument('database_name', help='Name of the database to fail over.')
        c.argument('server_name',
                   help='Name of the server containing the secondary replica that will become'
                   ' the new primary.')
        c.argument('resource_group_name',
                   help='Name of the resource group containing the secondary replica that'
                   ' will become the new primary.')
        c.argument('allow_data_loss',
                   help='If specified, the failover operation will allow data loss.')

    with self.argument_context('sql db replica delete-link') as c:
        c.argument('partner_server_name',
                   options_list=['--partner-server'],
                   help='Name of the server that the other replica is in.')
        c.argument('partner_resource_group_name',
                   options_list=['--partner-resource-group'],
                   help='Name of the resource group that the other replica is in. If unspecified,'
                   ' defaults to the first database\'s resource group.')

    #####
    #           sql db audit-policy & threat-policy
    #####
    def _configure_security_policy_storage_params(arg_ctx):
        storage_arg_group = 'Storage'

        arg_ctx.argument('storage_account',
                         options_list=['--storage-account'],
                         arg_group=storage_arg_group,
                         help='Name of the storage account.')

        arg_ctx.argument('storage_account_access_key',
                         options_list=['--storage-key'],
                         arg_group=storage_arg_group,
                         help='Access key for the storage account.')

        arg_ctx.argument('storage_endpoint',
                         arg_group=storage_arg_group,
                         help='The storage account endpoint.')

    with self.argument_context('sql db audit-policy update') as c:
        _configure_security_policy_storage_params(c)

        policy_arg_group = 'Policy'

        c.argument('state',
                   arg_group=policy_arg_group,
                   help='Auditing policy state',
                   arg_type=get_enum_type(BlobAuditingPolicyState))

        c.argument('audit_actions_and_groups',
                   options_list=['--actions'],
                   arg_group=policy_arg_group,
                   help='List of actions and action groups to audit.',
                   nargs='+')

        c.argument('retention_days',
                   arg_group=policy_arg_group,
                   help='The number of days to retain audit logs.')

    with self.argument_context('sql db threat-policy update') as c:
        _configure_security_policy_storage_params(c)

        policy_arg_group = 'Policy'
        notification_arg_group = 'Notification'

        c.argument('state',
                   arg_group=policy_arg_group,
                   help='Threat detection policy state',
                   arg_type=get_enum_type(SecurityAlertPolicyState))

        c.argument('retention_days',
                   arg_group=policy_arg_group,
                   help='The number of days to retain threat detection logs.')

        c.argument('disabled_alerts',
                   arg_group=policy_arg_group,
                   options_list=['--disabled-alerts'],
                   help='List of disabled alerts.',
                   nargs='+')

        c.argument('email_addresses',
                   arg_group=notification_arg_group,
                   options_list=['--email-addresses'],
                   help='List of email addresses that alerts are sent to.',
                   nargs='+')

        c.argument('email_account_admins',
                   arg_group=notification_arg_group,
                   options_list=['--email-account-admins'],
                   help='Whether the alert is sent to the account administrators.',
                   arg_type=get_enum_type(SecurityAlertPolicyEmailAccountAdmins))

        # TODO: use server default

    #####
    #           sql db transparent-data-encryption
    #####
    with self.argument_context('sql db tde') as c:
        c.argument('database_name',
                   options_list=['--database', '-d'],
                   required=True,
                   help='Name of the Azure SQL Database.')

    with self.argument_context('sql db tde set') as c:
        c.argument('status',
                   options_list=['--status'],
                   required=True,
                   help='Status of the transparent data encryption.',
                   arg_type=get_enum_type(TransparentDataEncryptionStatus))

    ###############################################
    #                sql dw                       #
    ###############################################
    with self.argument_context('sql dw') as c:
        c.argument('server_name',
                   arg_type=server_param_type,
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')

        c.argument('database_name', options_list=['--name', '-n'],
                   help='Name of the data warehouse.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        c.argument('max_size_bytes', options_list=['--max-size'],
                   type=SizeWithUnitConverter('B', result_type=int),
                   help='The max storage size of the data warehouse. If no unit is specified, defaults'
                   'to bytes (B).')

        c.argument('requested_service_objective_name',
                   options_list=['--service-objective'],
                   help='The service objective of the data warehouse.')

        c.argument('collation',
                   options_list=['--collation'],
                   help='The collation of the data warehouse.')

    with self.argument_context('sql dw create') as c:
        _configure_db_create_params(c, Engine.dw, CreateMode.default)

    with self.argument_context('sql dw show') as c:
        # Service tier advisors and transparent data encryption are not included in the first batch
        # of GA commands.
        c.ignore('expand')

    # Data Warehouse restore will not be included in the first batch of GA commands
    # (list_restore_points also applies to db, but it's not very useful. It's
    # mainly useful for dw.)
    # with ParametersContext(command='sql dw restore-point') as c:
    #     c.register_alias('database_name', ('--database', '-d'))

    ###############################################
    #                sql elastic-pool             #
    ###############################################
    with self.argument_context('sql elastic-pool') as c:
        c.argument('server_name',
                   arg_type=server_param_type,
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')

        c.argument('elastic_pool_name',
                   options_list=['--name', '-n'],
                   help='The name of the elastic pool.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        # --db-dtu-max and --db-dtu-min were the original param names, which is consistent with the
        # underlying REST API.
        # --db-max-dtu and --db-min-dtu are aliases which are consistent with the `sql elastic-pool
        # list-editions --show-details db-max-dtu db-min-dtu` parameter values. These are more
        # consistent with other az sql commands, but the original can't be removed due to
        # compatibility.
        c.argument('database_dtu_max', options_list=['--db-dtu-max', '--db-max-dtu'])
        c.argument('database_dtu_min', options_list=['--db-dtu-min', '--db-min-dtu'])

        # --storage was the original param name, which is consistent with the underlying REST API.
        # --max-size is an alias which is consistent with the `sql elastic-pool list-editions
        # --show-details max-size` parameter value and also matches `sql db --max-size` parameter name.
        c.argument('storage_mb', options_list=['--storage', '--max-size'],
                   type=SizeWithUnitConverter('MB', result_type=int),
                   help='The max storage size of the elastic pool. If no unit is specified, defaults'
                   ' to megabytes (MB).')

        c.argument('zone_redundant',
                   options_list=['--zone-redundant', '-z'],
                   help='Specifies whether to enable zone redundancy for the elastic pool.',
                   arg_type=get_three_state_flag())

    with self.argument_context('sql elastic-pool create') as c:
        c.expand('parameters', ElasticPool)
        # We have a wrapper function that determines server location so user doesn't need to specify
        # it as param.
        c.ignore('location')

    with self.argument_context('sql elastic-pool list-editions') as c:
        # Note that `ElasticPoolCapabilitiesAdditionalDetails` intentionally match param names to
        # other commands, such as `sql elastic-pool create --db-max-dtu --db-min-dtu --max-size`.
        c.argument('show_details',
                   options_list=['--show-details', '-d'],
                   help='List of additional details to include in output.',
                   nargs='+',
                   arg_type=get_enum_type(ElasticPoolCapabilitiesAdditionalDetails))

        search_arg_group = 'Search'

        # We could used 'arg_type=get_enum_type' here, but that will validate the inputs which means there
        # will be no way to query for new editions that are made available after
        # this version of CLI is released.
        c.argument('edition',
                   arg_group=search_arg_group,
                   help='Edition to search for. If unspecified, all editions are shown.')
        c.argument('dtu',
                   arg_group=search_arg_group,
                   help='Elastic pool DTU limit to search for. If unspecified, all DTU limits are shown.')

    with self.argument_context('sql elastic-pool update') as c:
        c.argument('database_dtu_max', help='The maximum DTU any one database can consume.')
        c.argument('database_dtu_min', help='The minimum DTU all databases are guaranteed.')
        c.argument('dtu', help='TThe total shared DTU for the elastic eool.')
        c.argument('storage_mb', help='Storage limit for the elastic pool in MB.')

    #####
    #           sql elastic-pool op
    #####
    with self.argument_context('sql elastic-pool op') as c:
        c.argument('elastic_pool_name',
                   options_list=['--elastic-pool'],
                   help='Name of the Azure SQL Elastic Pool.')

        c.argument('operation_id',
                   options_list=['--name', '-n'],
                   help='The unique name of the operation to cancel.')

    ###############################################
    #                sql server                   #
    ###############################################
    with self.argument_context('sql server') as c:
        c.argument('server_name', options_list=['--name', '-n'],
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')
        c.argument('administrator_login', options_list=['--admin-user', '-u'])
        c.argument('administrator_login_password', options_list=['--admin-password', '-p'])

    with self.argument_context('sql server create') as c:
        # Both administrator_login and administrator_login_password are required for server creation.
        # However these two parameters are given default value in the create_or_update function
        # signature, therefore, they can't be automatically converted to requirement arguments.
        c.expand('parameters', Server, patches={
            'administrator_login': patch_arg_make_required,
            'administrator_login_password': patch_arg_make_required
        })

        c.argument('assign_identity',
                   options_list=['--assign-identity', '-i'],
                   help='Generate and assign an Azure Active Directory Identity for this server'
                   'for use with key management services like Azure KeyVault.')

        # 12.0 is the only server version allowed and it's already the default.
        c.ignore('version')

        # Identity will be handled with its own parameter.
        c.ignore('identity')

    with self.argument_context('sql server update') as c:
        c.argument('administrator_login_password', help='The administrator login password.')
        c.argument('assign_identity',
                   options_list=['--assign_identity', '-i'],
                   help='Generate and assign an Azure Active Directory Identity for this server'
                   'for use with key management services like Azure KeyVault.')

    #####
    #           sql server ad-admin
    ######
    with self.argument_context('sql server ad-admin') as c:
        c.argument('server_name', options_list=['--server-name', '-s'],
                   help='The name of the SQL Server')
        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 ')
        c.ignore('tenant_id')

    with self.argument_context('sql server ad-admin create') as c:
        c.expand('properties', ServerAzureADAdministrator, patches={
            'tenant_id': patch_arg_make_optional})

    #####
    #           sql server conn-policy
    #####
    with self.argument_context('sql server conn-policy') as c:
        c.argument('server_name', arg_type=server_param_type)
        c.argument('connection_type', options_list=['--connection-type', '-t'],
                   arg_type=get_enum_type(ServerConnectionType))

    #####
    #           sql server dns-alias
    #####
    with self.argument_context('sql server dns-alias') as c:
        c.argument('server_name', arg_type=server_param_type)
        c.argument('dns_alias_name', options_list=('--name', '-n'))
        c.argument('original_server_name', options_list=('--original-server'),
                   help='The name of the server to which alias is currently pointing')
        c.argument('original_resource_group_name', options_list=('--original-resource-group'))
        c.argument('original_subscription_id', options_list=('--original-subscription-id'))

    #####
    #           sql server firewall-rule
    #####
    with self.argument_context('sql server firewall-rule') as c:
        # Help text needs to be specified because 'sql server firewall-rule update' is a custom
        # command.
        c.argument('server_name',
                   arg_type=server_param_type,
                   # Allow --ids command line argument. id_part=name is 1st name in uri
                   id_part='name')

        c.argument('firewall_rule_name',
                   options_list=['--name', '-n'],
                   help='The name of the firewall rule.',
                   # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
                   id_part='child_name_1')

        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.')

    #####
    #           sql server key
    #####
    with self.argument_context('sql server key') as c:
        c.argument('server_name', arg_type=server_param_type)
        c.argument('key_name', options_list=['--name', '-n'])
        c.argument('kid',
                   options_list=['--kid', '-k'],
                   required=True,
                   help='The Azure Key Vault key identifier of the server key. An example key identifier is '
                   '"https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"')

    #####
    #           sql server tde-key
    #####
    with self.argument_context('sql server tde-key') as c:
        c.argument('server_name', arg_type=server_param_type)

    with self.argument_context('sql server tde-key set') as c:
        c.argument('kid',
                   options_list=['--kid', '-k'],
                   help='The Azure Key Vault key identifier of the server key to be made encryption protector.'
                   'An example key identifier is '
                   '"https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"')
        c.argument('server_key_type',
                   options_list=['--server-key-type', '-t'],
                   help='The type of the server key',
                   arg_type=get_enum_type(ServerKeyType))

    #####
    #           sql server vnet-rule
    #####
    with self.argument_context('sql server vnet-rule') as c:
        # Help text needs to be specified because 'sql server vnet-rule create' is a custom
        # command.
        c.argument('server_name',
                   options_list=['--server', '-s'],
                   completer=get_resource_name_completion_list('Microsoft.SQL/servers'))

        c.argument('virtual_network_rule_name',
                   options_list=['--name', '-n'])

        c.argument('virtual_network_subnet_id',
                   options_list=['--subnet'],
                   help='Name or ID of the subnet that allows access to an Azure Sql 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 firewall rule before the virtual network has vnet service endpoint enabled',
                   arg_type=get_three_state_flag())

    with self.argument_context('sql server vnet-rule create') as c:
        c.extra('vnet_name', options_list=['--vnet-name'], help='The virtual network name')
示例#41
0
def load_arguments(self, _):  # pylint: disable=too-many-statements
    with self.argument_context('eventgrid') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('tags', arg_type=tags_type)
        c.argument('included_event_types', arg_type=included_event_types_type)
        c.argument('labels', arg_type=labels_type)
        c.argument(
            'endpoint_type',
            arg_type=get_enum_type([
                'webhook', 'eventhub', 'storagequeue', 'hybridconnection',
                'servicebusqueue', 'servicebustopic', 'azurefunction'
            ],
                                   default='webhook'))
        c.argument(
            'source_resource_id',
            help="Fully qualified identifier of the source Azure resource.")
        c.argument('resource_id',
                   deprecate_info=c.deprecate(redirect="--source-resource-id",
                                              expiration='2.1.0',
                                              hide=True),
                   help="Fully qualified identifier of the Azure resource.")
        c.argument(
            'endpoint',
            help=
            "Endpoint where EventGrid should deliver events matching this event subscription. For webhook endpoint type, this should be the corresponding webhook URL. For other endpoint types, this should be the Azure resource identifier of the endpoint."
        )
        c.argument('event_subscription_name',
                   help="Name of the event subscription.")
        c.argument(
            'subject_begins_with',
            help=
            "An optional string to filter events for an event subscription based on a prefix. Wildcard characters are not supported."
        )
        c.argument(
            'subject_ends_with',
            help=
            "An optional string to filter events for an event subscription based on a suffix. Wildcard characters are not supported."
        )
        c.argument('topic_type_name', help="Name of the topic type.")
        c.argument(
            'is_subject_case_sensitive',
            arg_type=get_three_state_flag(),
            options_list=['--subject-case-sensitive'],
            help=
            "Specify to indicate whether the subject fields should be compared in a case sensitive manner. True if flag present.",
        )
        c.argument('input_mapping_fields', arg_type=input_mapping_fields_type)
        c.argument('input_mapping_default_values',
                   arg_type=input_mapping_default_values_type)
        c.argument('input_schema', arg_type=input_schema_type)
        c.argument('odata_query', arg_type=odata_query_type)
        c.argument('domain_name', arg_type=domain_name_type)
        c.argument('domain_topic_name', arg_type=domain_topic_name_type)

    with self.argument_context('eventgrid topic') as c:
        c.argument('topic_name',
                   arg_type=name_type,
                   help='Name of the topic.',
                   id_part='name',
                   completer=get_resource_name_completion_list(
                       'Microsoft.EventGrid/topics'))

    with self.argument_context('eventgrid topic key') as c:
        c.argument('topic_name',
                   arg_type=name_type,
                   help='Name of the topic',
                   id_part=None,
                   completer=get_resource_name_completion_list(
                       'Microsoft.EventGrid/topics'))

    with self.argument_context('eventgrid topic list') as c:
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid domain') as c:
        c.argument('domain_name',
                   arg_type=domain_name_type,
                   options_list=['--name', '-n'],
                   id_part='name')

    with self.argument_context('eventgrid domain list') as c:
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid domain key') as c:
        c.argument('domain_name',
                   arg_type=domain_name_type,
                   options_list=['--name', '-n'],
                   id_part=None)

    with self.argument_context('eventgrid domain topic') as c:
        c.argument('domain_name', arg_type=domain_name_type, id_part='name')
        c.argument('domain_topic_name',
                   arg_type=domain_topic_name_type,
                   options_list=['--name', '-n'],
                   id_part='topics')

    with self.argument_context('eventgrid domain topic list') as c:
        c.argument('domain_name', arg_type=domain_name_type, id_part=None)
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid event-subscription') as c:
        c.argument('topic_name',
                   deprecate_info=c.deprecate(expiration='2.1.0', hide=True),
                   help='Name of Event Grid topic.',
                   options_list=['--topic-name'],
                   completer=get_resource_name_completion_list(
                       'Microsoft.EventGrid/topics'))
        c.argument('event_subscription_name',
                   arg_type=name_type,
                   help='Name of the event subscription.')
        c.argument(
            'event_delivery_schema',
            arg_type=get_enum_type([
                'eventgridschema', 'custominputschema', 'cloudeventschemav1_0'
            ]),
            help=
            'The schema in which events should be delivered for this event subscription. By default, events will be delivered in the same schema in which they are published (based on the corresponding topic\'s input schema).'
        )
        c.argument(
            'max_delivery_attempts',
            help=
            "Maximum number of delivery attempts. Must be a number between 1 and 30."
        )
        c.argument(
            'max_events_per_batch',
            help=
            "Maximum number of events in a batch. Must be a number between 1 and 5000."
        )
        c.argument(
            'preferred_batch_size_in_kilobytes',
            help=
            "Preferred batch size in kilobytes. Must be a number between 1 and 1024."
        )
        c.argument(
            'event_ttl',
            help=
            "Event time to live (in minutes). Must be a number between 1 and 1440."
        )
        c.argument(
            'deadletter_endpoint',
            help=
            "The Azure resource ID of an Azure Storage blob container destination where EventGrid should deadletter undeliverable events for this event subscription."
        )
        c.argument('advanced_filter',
                   action=EventSubscriptionAddFilter,
                   nargs='+')
        c.argument(
            'expiration_date',
            help=
            "Date or datetime (in UTC, e.g. '2018-11-30T11:59:59+00:00' or '2018-11-30') after which the event subscription would expire. By default, there is no expiration for the event subscription."
        )
        c.argument(
            'azure_active_directory_tenant_id',
            help=
            "The Azure Active Directory Tenant Id to get the access token that will be included as the bearer token in delivery requests. Applicable only for webhook as a destination"
        )
        c.argument(
            'azure_active_directory_application_id_or_uri',
            help=
            "The Azure Active Directory Application Id or Uri to get the access token that will be included as the bearer token in delivery requests. Applicable only for webhook as a destination"
        )

    with self.argument_context('eventgrid event-subscription create') as c:
        c.argument('resource_group_name',
                   deprecate_info=c.deprecate(expiration='2.1.0', hide=True),
                   arg_type=resource_group_name_type)

    with self.argument_context('eventgrid event-subscription delete') as c:
        c.argument('resource_group_name',
                   deprecate_info=c.deprecate(expiration='2.1.0', hide=True),
                   arg_type=resource_group_name_type)

    with self.argument_context('eventgrid event-subscription update') as c:
        c.argument('resource_group_name',
                   deprecate_info=c.deprecate(expiration='2.1.0', hide=True),
                   arg_type=resource_group_name_type)

    with self.argument_context('eventgrid event-subscription list') as c:
        c.argument('odata_query', arg_type=odata_query_type, id_part=None)

    with self.argument_context('eventgrid event-subscription show') as c:
        c.argument('resource_group_name',
                   deprecate_info=c.deprecate(expiration='2.1.0', hide=True),
                   arg_type=resource_group_name_type)
        c.argument(
            'include_full_endpoint_url',
            arg_type=get_three_state_flag(),
            options_list=['--include-full-endpoint-url'],
            help=
            "Specify to indicate whether the full endpoint URL should be returned. True if flag present.",
        )

    with self.argument_context('eventgrid topic-type') as c:
        c.argument('topic_type_name',
                   arg_type=name_type,
                   help="Name of the topic type.",
                   completer=get_resource_name_completion_list(
                       'Microsoft.EventGrid/topictypes'))
示例#42
0
def load_arguments(self, _):

    with self.argument_context('managed-network mn list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument(
            'top',
            type=int,
            help=
            'May be used to limit the number of results in a page for list queries.'
        )
        c.argument(
            'skiptoken',
            type=str,
            help=
            'Skiptoken is only used if a previous operation returned a partial '
            'result. If a previous response contains a nextLink element, the value of the nextLink element will '
            'include a skiptoken parameter that specifies a starting point to use for subsequent calls.'
        )

    with self.argument_context('managed-network mn create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   options_list=['--name', '-n', '--managed-network-name'],
                   type=str,
                   help='The name of the Managed Network.')
        c.argument(
            'managed_network',
            type=validate_file_or_dict,
            help='Parameters supplied to the create/update a '
            'Managed Network Resource Expected value: json-string/@json-file.')

    with self.argument_context('managed-network mn update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   options_list=['--name', '-n', '--managed-network-name'],
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('tags', tags_type)

    with self.argument_context('managed-network mn delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   options_list=['--name', '-n', '--managed-network-name'],
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')

    with self.argument_context('managed-network mn show-modify') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   options_list=['--name', '-n', '--managed-network-name'],
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')

    with self.argument_context(
            'managed-network mn scope-assignment list') as c:
        c.argument('scope',
                   type=str,
                   help='The base resource of the scope assignment.')

    with self.argument_context(
            'managed-network mn scope-assignment show') as c:
        c.argument('scope',
                   type=str,
                   help='The base resource of the scope assignment.')
        c.argument('scope_assignment_name',
                   options_list=['--name', '-n', '--scope-assignment-name'],
                   type=str,
                   help='The name of the scope assignment to get.')

    with self.argument_context(
            'managed-network mn scope-assignment create') as c:
        c.argument(
            'scope',
            type=str,
            help=
            'The base resource of the scope assignment to create. The scope can be any '
            'REST resource instance. For example, use \'subscriptions/{subscription-id}\' for a subscription, '
            '\'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}\' for a resource group, and '
            '\'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider'
            '}/{resource-type}/{resource-name}\' for a resource.')
        c.argument('scope_assignment_name',
                   options_list=['--name', '-n', '--scope-assignment-name'],
                   type=str,
                   help='The name of the scope assignment to create.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument(
            'assigned_managed_network',
            type=str,
            help='The managed network ID with scope will be assigned to.')

    with self.argument_context(
            'managed-network mn scope-assignment update') as c:
        c.argument(
            'scope',
            type=str,
            help=
            'The base resource of the scope assignment to create. The scope can be any '
            'REST resource instance. For example, use \'subscriptions/{subscription-id}\' for a subscription, '
            '\'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}\' for a resource group, and '
            '\'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider'
            '}/{resource-type}/{resource-name}\' for a resource.')
        c.argument('scope_assignment_name',
                   options_list=['--name', '-n', '--scope-assignment-name'],
                   type=str,
                   help='The name of the scope assignment to create.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument(
            'assigned_managed_network',
            type=str,
            help='The managed network ID with scope will be assigned to.')
        c.ignore('parameters')

    with self.argument_context(
            'managed-network mn scope-assignment delete') as c:
        c.argument('scope',
                   type=str,
                   help='The scope of the scope assignment to delete.')
        c.argument('scope_assignment_name',
                   options_list=['--name', '-n', '--scope-assignment-name'],
                   type=str,
                   help='The name of the scope assignment to delete.')

    with self.argument_context('managed-network mn group list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.')
        c.argument(
            'top',
            type=int,
            help=
            'May be used to limit the number of results in a page for list queries.'
        )
        c.argument(
            'skiptoken',
            type=str,
            help=
            'Skiptoken is only used if a previous operation returned a partial '
            'result. If a previous response contains a nextLink element, the value of the nextLink element will '
            'include a skiptoken parameter that specifies a starting point to use for subsequent calls.'
        )

    with self.argument_context('managed-network mn group show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('group_name',
                   type=str,
                   help='The name of the Managed Network Group.',
                   id_part='child_name_1')

    with self.argument_context('managed-network mn group create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.')
        c.argument('group_name',
                   type=str,
                   help='The name of the Managed Network Group.')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument(
            'management_groups',
            type=validate_file_or_dict,
            help='The collection of management groups covered '
            'by the Managed Network Expected value: json-string/@json-file.')
        c.argument('subscriptions',
                   action=AddSubscriptions,
                   nargs='+',
                   help='The collection of subscriptions covered '
                   'by the Managed Network')
        c.argument('virtual_networks',
                   action=AddVirtualNetworks,
                   nargs='+',
                   help='The collection of virtual nets '
                   'covered by the Managed Network')
        c.argument('subnets',
                   action=AddSubnets,
                   nargs='+',
                   help='The collection of  subnets covered by the Managed '
                   'Network')

    with self.argument_context('managed-network mn group update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('group_name',
                   type=str,
                   help='The name of the Managed Network Group.',
                   id_part='child_name_1')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument(
            'management_groups',
            type=validate_file_or_dict,
            help='The collection of management groups covered '
            'by the Managed Network Expected value: json-string/@json-file.')
        c.argument('subscriptions',
                   action=AddSubscriptions,
                   nargs='+',
                   help='The collection of subscriptions covered '
                   'by the Managed Network')
        c.argument('virtual_networks',
                   action=AddVirtualNetworks,
                   nargs='+',
                   help='The collection of virtual nets '
                   'covered by the Managed Network')
        c.argument('subnets',
                   action=AddSubnets,
                   nargs='+',
                   help='The collection of  subnets covered by the Managed '
                   'Network')
        c.ignore('managed_network_group_name', 'managed_network_group')

    with self.argument_context('managed-network mn group delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('group_name',
                   type=str,
                   help='The name of the Managed Network Group.',
                   id_part='child_name_1')

    with self.argument_context('managed-network mn group wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('group_name',
                   type=str,
                   help='The name of the Managed Network Group.',
                   id_part='child_name_1')

    with self.argument_context(
            'managed-network managed-network-peering-policy list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.')
        c.argument(
            'top',
            type=int,
            help=
            'May be used to limit the number of results in a page for list queries.'
        )
        c.argument(
            'skiptoken',
            type=str,
            help=
            'Skiptoken is only used if a previous operation returned a partial '
            'result. If a previous response contains a nextLink element, the value of the nextLink element will '
            'include a skiptoken parameter that specifies a starting point to use for subsequent calls.'
        )

    with self.argument_context(
            'managed-network managed-network-peering-policy show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.',
                   id_part='child_name_1')

    with self.argument_context(
            'managed-network managed-network-peering-policy hub-and-spoke-topology create'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.')
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('hub',
                   action=AddHub,
                   nargs='+',
                   help='Gets or sets the hub virtual network ID')
        c.argument('spokes',
                   action=AddSpokes,
                   nargs='+',
                   help='Gets or sets the spokes group IDs')
        c.argument('mesh',
                   action=AddMesh,
                   nargs='+',
                   help='Gets or sets the mesh group IDs')
        c.argument('managed_network_policy',
                   type=str,
                   help='inside managedNetworkPolicy')

    with self.argument_context(
            'managed-network managed-network-peering-policy mesh-topology create'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.')
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('hub',
                   action=AddHub,
                   nargs='+',
                   help='Gets or sets the hub virtual network ID')
        c.argument('spokes',
                   action=AddSpokes,
                   nargs='+',
                   help='Gets or sets the spokes group IDs')
        c.argument('mesh',
                   action=AddMesh,
                   nargs='+',
                   help='Gets or sets the mesh group IDs')
        c.argument('managed_network_policy',
                   type=str,
                   help='inside managedNetworkPolicy')

    with self.argument_context(
            'managed-network managed-network-peering-policy hub-and-spoke-topology update'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.',
                   id_part='child_name_1')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('hub',
                   action=AddHub,
                   nargs='+',
                   help='Gets or sets the hub virtual network ID')
        c.argument('spokes',
                   action=AddSpokes,
                   nargs='+',
                   help='Gets or sets the spokes group IDs')
        c.argument('mesh',
                   action=AddMesh,
                   nargs='+',
                   help='Gets or sets the mesh group IDs')
        c.argument('managed_network_policy',
                   type=str,
                   help='inside managedNetworkPolicy')
        c.ignore('managed_network_peering_policy_name')

    with self.argument_context(
            'managed-network managed-network-peering-policy mesh-topology update'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.',
                   id_part='child_name_1')
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('hub',
                   action=AddHub,
                   nargs='+',
                   help='Gets or sets the hub virtual network ID')
        c.argument('spokes',
                   action=AddSpokes,
                   nargs='+',
                   help='Gets or sets the spokes group IDs')
        c.argument('mesh',
                   action=AddMesh,
                   nargs='+',
                   help='Gets or sets the mesh group IDs')
        c.argument('managed_network_policy',
                   type=str,
                   help='inside managedNetworkPolicy')
        c.ignore('managed_network_peering_policy_name')

    with self.argument_context(
            'managed-network managed-network-peering-policy delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name',
                   max_api='2020-05-01',
                   min_api='2019-05-01',
                   resource_type=ResourceType.DATA_NETWORK)
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.',
                   id_part='child_name_1')

    with self.argument_context(
            'managed-network managed-network-peering-policy wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('managed_network_name',
                   type=str,
                   help='The name of the Managed Network.',
                   id_part='name')
        c.argument('policy_name',
                   type=str,
                   help='The name of the Managed Network Peering Policy.',
                   id_part='child_name_1')
示例#43
0
def load_arguments(self, _):

    with self.argument_context('sql') as c:
        c.argument('location_name', arg_type=get_location_type(self.cli_ctx))
        c.argument('usage_name', options_list=['--usage', '-u'])
        c.argument('tags', arg_type=tags_type)

    with self.argument_context('sql db') as c:
        c.argument('server_name', arg_type=server_param_type)

        c.argument(
            'database_name',
            options_list=['--name', '-n'],
            help='Name of the Azure SQL Database.',
            # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
            id_part='child_name_1')

        c.argument('max_size_bytes', arg_type=max_size_bytes_param_type)

        creation_arg_group = 'Creation'

        c.argument('collation', arg_group=creation_arg_group)

        c.argument('catalog_collation',
                   arg_group=creation_arg_group,
                   arg_type=get_enum_type(CatalogCollationType))

        c.argument('sample_name', arg_group=creation_arg_group)

        c.argument('license_type', arg_type=get_enum_type(DatabaseLicenseType))

        # Needs testing
        c.ignore('read_scale')
        # c.argument('read_scale',
        #            arg_type=get_three_state_flag(DatabaseReadScale.enabled.value,
        #                                         DatabaseReadScale.disabled.value,
        #                                         return_label=True))

        c.argument('zone_redundant', arg_type=zone_redundant_param_type)

        c.argument(
            'tier',
            arg_type=tier_param_type,
            help=
            'The edition component of the sku. Allowed values include: Basic, Standard, '
            'Premium, GeneralPurpose, BusinessCritical.')

        c.argument(
            'capacity',
            arg_type=capacity_param_type,
            arg_group=sku_component_arg_group,
            help=
            'The capacity component of the sku in integer number of DTUs or vcores.'
        )

        c.argument(
            'family',
            arg_type=family_param_type,
            help=
            'The compute generation component of the sku (for vcore skus only). '
            'Allowed values include: Gen4, Gen5.')

    with self.argument_context('sql db create') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.default)

    with self.argument_context('sql db copy') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.copy)

        c.argument(
            'dest_name',
            help=
            'Name of the database that will be created as the copy destination.'
        )

        c.argument('dest_resource_group_name',
                   options_list=['--dest-resource-group'],
                   help='Name of the resouce group to create the copy in.'
                   ' If unspecified, defaults to the origin resource group.')

        c.argument('dest_server_name',
                   options_list=['--dest-server'],
                   help='Name of the server to create the copy in.'
                   ' If unspecified, defaults to the origin server.')

    with self.argument_context('sql db rename') as c:
        c.argument('new_name',
                   help='The new name that the database will be renamed to.')

    with self.argument_context('sql db restore') as c:
        _configure_db_create_params(c, Engine.db,
                                    CreateMode.point_in_time_restore)

        c.argument(
            'dest_name',
            help=
            'Name of the database that will be created as the restore destination.'
        )

        restore_point_arg_group = 'Restore Point'

        c.argument(
            'restore_point_in_time',
            options_list=['--time', '-t'],
            arg_group=restore_point_arg_group,
            help=
            'The point in time of the source database that will be restored to create the'
            ' new database. Must be greater than or equal to the source database\'s'
            ' earliestRestoreDate value. Either --time or --deleted-time (or both) must be specified.'
        )

        c.argument(
            'source_database_deletion_date',
            options_list=['--deleted-time'],
            arg_group=restore_point_arg_group,
            help=
            'If specified, restore from a deleted database instead of from an existing database.'
            ' Must match the deleted time of a deleted database in the same server.'
            ' Either --time or --deleted-time (or both) must be specified.')

    with self.argument_context('sql db show') as c:
        # Service tier advisors and transparent data encryption are not included in the first batch
        # of GA commands.
        c.ignore('expand')

    with self.argument_context('sql db list') as c:
        c.argument(
            'elastic_pool_name',
            options_list=['--elastic-pool'],
            help='If specified, lists only the databases in this elastic pool')

    with self.argument_context('sql db list-editions') as c:
        c.argument(
            'show_details',
            options_list=['--show-details', '-d'],
            help='List of additional details to include in output.',
            nargs='+',
            arg_type=get_enum_type(DatabaseCapabilitiesAdditionalDetails))

        c.argument('available', arg_type=available_param_type)

        search_arg_group = 'Search'

        # We could used get_enum_type here, but that will validate the inputs which means there
        # will be no way to query for new editions/service objectives that are made available after
        # this version of CLI is released.
        c.argument(
            'edition',
            arg_type=tier_param_type,
            arg_group=search_arg_group,
            help=
            'Edition to search for. If unspecified, all editions are shown.')

        c.argument(
            'service_objective',
            arg_group=search_arg_group,
            help=
            'Service objective to search for. If unspecified, all service objectives are shown.'
        )

        c.argument(
            'dtu',
            arg_group=search_arg_group,
            help=
            'Number of DTUs to search for. If unspecified, all DTU sizes are shown.'
        )

        c.argument(
            'vcores',
            arg_group=search_arg_group,
            help=
            'Number of vcores to search for. If unspecified, all vcore sizes are shown.'
        )

    with self.argument_context('sql db update') as c:
        c.argument(
            'service_objective',
            arg_group=sku_arg_group,
            help=
            'The name of the new service objective. If this is a standalone db service'
            ' objective and the db is currently in an elastic pool, then the db is removed from'
            ' the pool.')

        c.argument(
            'elastic_pool_id',
            arg_type=elastic_pool_id_param_type,
            help=
            'The name or resource id of the elastic pool to move the database into.'
        )

        c.argument(
            'max_size_bytes',
            help='The new maximum size of the database expressed in bytes.')

    with self.argument_context('sql db export') as c:
        # Create args that will be used to build up the ExportRequest object
        create_args_for_complex_type(c, 'parameters', ExportRequest, [
            'administrator_login',
            'administrator_login_password',
            'authentication_type',
            'storage_key',
            'storage_key_type',
            'storage_uri',
        ])

        c.argument('administrator_login', options_list=['--admin-user', '-u'])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument('authentication_type',
                   options_list=['--auth-type', '-a'],
                   arg_type=get_enum_type(AuthenticationType))

        c.argument('storage_key_type', arg_type=get_enum_type(StorageKeyType))

    with self.argument_context('sql db import') as c:
        # Create args that will be used to build up the ImportExtensionRequest object
        create_args_for_complex_type(c, 'parameters', ImportExtensionRequest, [
            'administrator_login', 'administrator_login_password',
            'authentication_type', 'storage_key', 'storage_key_type',
            'storage_uri'
        ])

        c.argument('administrator_login', options_list=['--admin-user', '-u'])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument('authentication_type',
                   options_list=['--auth-type', '-a'],
                   arg_type=get_enum_type(AuthenticationType))

        c.argument('storage_key_type', arg_type=get_enum_type(StorageKeyType))

        # The parameter name '--name' is used for 'database_name', so we need to give a different name
        # for the import extension 'name' parameter to avoid conflicts. This parameter is actually not
        # needed, but we still need to avoid this conflict.
        c.argument('name', options_list=['--not-name'], arg_type=ignore_type)

    with self.argument_context('sql db show-connection-string') as c:
        c.argument('client_provider',
                   options_list=['--client', '-c'],
                   help='Type of client connection provider.',
                   arg_type=get_enum_type(ClientType))

        auth_group = 'Authentication'

        c.argument('auth_type',
                   options_list=['--auth-type', '-a'],
                   arg_group=auth_group,
                   help='Type of authentication.',
                   arg_type=get_enum_type(ClientAuthenticationType))

    #####
    #           sql db op
    #####
    with self.argument_context('sql db op') as c:
        c.argument('database_name',
                   options_list=['--database', '-d'],
                   required=True,
                   help='Name of the Azure SQL Database.')

        c.argument('operation_id',
                   options_list=['--name', '-n'],
                   required=True,
                   help='The unique name of the operation to cancel.')

    #####
    #           sql db replica
    #####
    with self.argument_context('sql db replica create') as c:
        _configure_db_create_params(c, Engine.db, CreateMode.secondary)

        c.argument(
            'partner_resource_group_name',
            options_list=['--partner-resource-group'],
            help='Name of the resource group to create the new replica in.'
            ' If unspecified, defaults to the origin resource group.')

        c.argument('partner_server_name',
                   options_list=['--partner-server'],
                   help='Name of the server to create the new replica in.')

    with self.argument_context('sql db replica set-primary') as c:
        c.argument('database_name', help='Name of the database to fail over.')

        c.argument(
            'server_name',
            help=
            'Name of the server containing the secondary replica that will become'
            ' the new primary. ' + server_configure_help)

        c.argument(
            'resource_group_name',
            help=
            'Name of the resource group containing the secondary replica that'
            ' will become the new primary.')

        c.argument(
            'allow_data_loss',
            help='If specified, the failover operation will allow data loss.')

    with self.argument_context('sql db replica delete-link') as c:
        c.argument('partner_server_name',
                   options_list=['--partner-server'],
                   help='Name of the server that the other replica is in.')

        c.argument(
            'partner_resource_group_name',
            options_list=['--partner-resource-group'],
            help=
            'Name of the resource group that the other replica is in. If unspecified,'
            ' defaults to the first database\'s resource group.')

    #####
    #           sql db audit-policy & threat-policy
    #####
    def _configure_security_policy_storage_params(arg_ctx):
        storage_arg_group = 'Storage'

        arg_ctx.argument('storage_account',
                         options_list=['--storage-account'],
                         arg_group=storage_arg_group,
                         help='Name of the storage account.')

        arg_ctx.argument('storage_account_access_key',
                         options_list=['--storage-key'],
                         arg_group=storage_arg_group,
                         help='Access key for the storage account.')

        arg_ctx.argument('storage_endpoint',
                         arg_group=storage_arg_group,
                         help='The storage account endpoint.')

    with self.argument_context('sql db audit-policy update') as c:
        _configure_security_policy_storage_params(c)

        policy_arg_group = 'Policy'

        c.argument('state',
                   arg_group=policy_arg_group,
                   help='Auditing policy state',
                   arg_type=get_enum_type(BlobAuditingPolicyState))

        c.argument('audit_actions_and_groups',
                   options_list=['--actions'],
                   arg_group=policy_arg_group,
                   help='List of actions and action groups to audit.',
                   nargs='+')

        c.argument('retention_days',
                   arg_group=policy_arg_group,
                   help='The number of days to retain audit logs.')

    with self.argument_context('sql db threat-policy update') as c:
        _configure_security_policy_storage_params(c)

        policy_arg_group = 'Policy'
        notification_arg_group = 'Notification'

        c.argument('state',
                   arg_group=policy_arg_group,
                   help='Threat detection policy state',
                   arg_type=get_enum_type(SecurityAlertPolicyState))

        c.argument('retention_days',
                   arg_group=policy_arg_group,
                   help='The number of days to retain threat detection logs.')

        c.argument('disabled_alerts',
                   arg_group=policy_arg_group,
                   options_list=['--disabled-alerts'],
                   help='List of disabled alerts.',
                   nargs='+')

        c.argument('email_addresses',
                   arg_group=notification_arg_group,
                   options_list=['--email-addresses'],
                   help='List of email addresses that alerts are sent to.',
                   nargs='+')

        c.argument(
            'email_account_admins',
            arg_group=notification_arg_group,
            options_list=['--email-account-admins'],
            help='Whether the alert is sent to the account administrators.',
            arg_type=get_enum_type(SecurityAlertPolicyEmailAccountAdmins))

        # TODO: use server default

    #####
    #           sql db transparent-data-encryption
    #####
    with self.argument_context('sql db tde') as c:
        c.argument('database_name',
                   options_list=['--database', '-d'],
                   required=True,
                   help='Name of the Azure SQL Database.')

    with self.argument_context('sql db tde set') as c:
        c.argument('status',
                   options_list=['--status'],
                   required=True,
                   help='Status of the transparent data encryption.',
                   arg_type=get_enum_type(TransparentDataEncryptionStatus))

    ###############################################
    #                sql dw                       #
    ###############################################
    with self.argument_context('sql dw') as c:
        c.argument('server_name', arg_type=server_param_type)

        c.argument(
            'database_name',
            options_list=['--name', '-n'],
            help='Name of the data warehouse.',
            # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
            id_part='child_name_1')

        c.argument('max_size_bytes', arg_type=max_size_bytes_param_type)

        c.argument(
            'service_objective',
            help='The service objective of the data warehouse. For example: ' +
            dw_service_objective_examples)

        c.argument('collation', help='The collation of the data warehouse.')

    with self.argument_context('sql dw create') as c:
        _configure_db_create_params(c, Engine.dw, CreateMode.default)

    with self.argument_context('sql dw show') as c:
        # Service tier advisors and transparent data encryption are not included in the first batch
        # of GA commands.
        c.ignore('expand')

    # Data Warehouse restore will not be included in the first batch of GA commands
    # (list_restore_points also applies to db, but it's not very useful. It's
    # mainly useful for dw.)
    # with ParametersContext(command='sql dw restore-point') as c:
    #     c.register_alias('database_name', ('--database', '-d'))

    ###############################################
    #                sql elastic-pool             #
    ###############################################
    with self.argument_context('sql elastic-pool') as c:
        c.argument('server_name', arg_type=server_param_type)

        c.argument(
            'elastic_pool_name',
            options_list=['--name', '-n'],
            help='The name of the elastic pool.',
            # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
            id_part='child_name_1')

        # --db-dtu-max and --db-dtu-min were the original param names, which is consistent with the
        # 2014-04-01 REST API.
        # --db-max-dtu and --db-min-dtu are aliases which are consistent with the `sql elastic-pool
        # list-editions --show-details db-max-dtu db-min-dtu` parameter values. These are more
        # consistent with other az sql commands, but the original can't be removed due to
        # compatibility.
        c.argument(
            'max_capacity',
            options_list=['--db-dtu-max', '--db-max-dtu', '--db-max-capacity'],
            help=
            'The maximum capacity (in DTUs or vcores) any one database can consume.'
        )

        c.argument(
            'min_capacity',
            options_list=['--db-dtu-min', '--db-min-dtu', '--db-min-capacity'],
            help=
            'The minumum capacity (in DTUs or vcores) each database is guaranteed.'
        )

        # --storage was the original param name, which is consistent with the underlying REST API.
        # --max-size is an alias which is consistent with the `sql elastic-pool list-editions
        # --show-details max-size` parameter value and also matches `sql db --max-size` parameter name.
        c.argument('max_size_bytes',
                   arg_type=max_size_bytes_param_type,
                   options_list=['--max-size', '--storage'])

        c.argument('license_type',
                   arg_type=get_enum_type(ElasticPoolLicenseType))

        c.argument('zone_redundant', arg_type=zone_redundant_param_type)

        c.argument(
            'tier',
            arg_type=tier_param_type,
            help=
            'The edition component of the sku. Allowed values include: Basic, Standard, '
            'Premium, GeneralPurpose, BusinessCritical.')

        c.argument(
            'capacity',
            arg_type=capacity_or_dtu_param_type,
            help=
            'The capacity component of the sku in integer number of DTUs or vcores.'
        )

        c.argument(
            'family',
            arg_type=family_param_type,
            help=
            'The compute generation component of the sku (for vcore skus only). '
            'Allowed values include: Gen4, Gen5.')

    with self.argument_context('sql elastic-pool create') as c:
        # Create args that will be used to build up the ElasticPool object
        create_args_for_complex_type(c, 'parameters', ElasticPool, [
            'license_type',
            'max_size_bytes',
            'name',
            'per_database_settings',
            'tags',
            'zone_redundant',
        ])

        # Create args that will be used to build up the ElasticPoolPerDatabaseSettings object
        create_args_for_complex_type(c, 'per_database_settings',
                                     ElasticPoolPerDatabaseSettings, [
                                         'max_capacity',
                                         'min_capacity',
                                     ])

        # Create args that will be used to build up the ElasticPool Sku object
        create_args_for_complex_type(c, 'sku', Sku, [
            'capacity',
            'family',
            'name',
            'tier',
        ])

        c.ignore('name')  # Hide sku name

    with self.argument_context('sql elastic-pool list-editions') as c:
        # Note that `ElasticPoolCapabilitiesAdditionalDetails` intentionally match param names to
        # other commands, such as `sql elastic-pool create --db-max-dtu --db-min-dtu --max-size`.
        c.argument(
            'show_details',
            options_list=['--show-details', '-d'],
            help='List of additional details to include in output.',
            nargs='+',
            arg_type=get_enum_type(ElasticPoolCapabilitiesAdditionalDetails))

        c.argument('available', arg_type=available_param_type)

        search_arg_group = 'Search'

        # We could used 'arg_type=get_enum_type' here, but that will validate the inputs which means there
        # will be no way to query for new editions that are made available after
        # this version of CLI is released.
        c.argument(
            'edition',
            arg_type=tier_param_type,
            arg_group=search_arg_group,
            help=
            'Edition to search for. If unspecified, all editions are shown.')

        c.argument(
            'dtu',
            arg_group=search_arg_group,
            help=
            'Number of DTUs to search for. If unspecified, all DTU sizes are shown.'
        )

        c.argument(
            'vcores',
            arg_group=search_arg_group,
            help=
            'Number of vcores to search for. If unspecified, all vcore sizes are shown.'
        )

    with self.argument_context('sql elastic-pool update') as c:
        c.argument('database_dtu_max',
                   help='The maximum DTU any one database can consume.')

        c.argument('database_dtu_min',
                   help='The minimum DTU all databases are guaranteed.')

        c.argument('storage_mb',
                   help='Storage limit for the elastic pool in MB.')

    #####
    #           sql elastic-pool op
    #####
    with self.argument_context('sql elastic-pool op') as c:
        c.argument('elastic_pool_name',
                   options_list=['--elastic-pool'],
                   help='Name of the Azure SQL Elastic Pool.')

        c.argument('operation_id',
                   options_list=['--name', '-n'],
                   help='The unique name of the operation to cancel.')

    ###############################################
    #                sql server                   #
    ###############################################
    with self.argument_context('sql server') as c:
        c.argument('server_name',
                   arg_type=server_param_type,
                   options_list=['--name', '-n'])

        c.argument('administrator_login', options_list=['--admin-user', '-u'])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument(
            'assign_identity',
            options_list=['--assign_identity', '-i'],
            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('sql server create') as c:
        # Create args that will be used to build up the Server object
        create_args_for_complex_type(c, 'parameters', Server, [
            'administrator_login', 'administrator_login_password', 'location'
        ])

        c.argument('administrator_login', required=True)

        c.argument('administrator_login_password', required=True)

        c.argument(
            'assign_identity',
            options_list=['--assign-identity', '-i'],
            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('sql server update') as c:
        c.argument('administrator_login_password',
                   help='The administrator login password.')

    #####
    #           sql server ad-admin
    ######
    with self.argument_context('sql server ad-admin') as c:
        # The options list should be ['--server', '-s'], but in the originally released version it was
        # ['--server-name'] which we must keep for backward compatibility - but we should deprecate it.
        c.argument('server_name',
                   options_list=['--server-name', '--server', '-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 ')

        c.ignore('tenant_id')

    with self.argument_context('sql server ad-admin create') as c:
        # Create args that will be used to build up the ServerAzureADAdministrator object
        create_args_for_complex_type(c, 'properties',
                                     ServerAzureADAdministrator, [
                                         'login',
                                         'sid',
                                     ])

    #####
    #           sql server conn-policy
    #####
    with self.argument_context('sql server conn-policy') as c:
        c.argument('server_name', arg_type=server_param_type)

        c.argument('connection_type',
                   options_list=['--connection-type', '-t'],
                   arg_type=get_enum_type(ServerConnectionType))

    #####
    #           sql server dns-alias
    #####
    with self.argument_context('sql server dns-alias') as c:
        c.argument('server_name', arg_type=server_param_type)

        c.argument('dns_alias_name', options_list=('--name', '-n'))

        c.argument(
            'original_server_name',
            options_list=('--original-server'),
            help='The name of the server to which alias is currently pointing')

        c.argument('original_resource_group_name',
                   options_list=('--original-resource-group'))

        c.argument('original_subscription_id',
                   options_list=('--original-subscription-id'))

    #####
    #           sql server firewall-rule
    #####
    with self.argument_context('sql server firewall-rule') as c:
        # Help text needs to be specified because 'sql server firewall-rule update' is a custom
        # command.
        c.argument('server_name', arg_type=server_param_type)

        c.argument(
            'firewall_rule_name',
            options_list=['--name', '-n'],
            help='The name of the firewall rule.',
            # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
            id_part='child_name_1')

        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.')

    #####
    #           sql server key
    #####
    with self.argument_context('sql server key') as c:
        c.argument('server_name', arg_type=server_param_type)

        c.argument('key_name', options_list=['--name', '-n'])

        c.argument(
            'kid',
            options_list=['--kid', '-k'],
            required=True,
            help=
            'The Azure Key Vault key identifier of the server key. An example key identifier is '
            '"https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"'
        )

    #####
    #           sql server tde-key
    #####
    with self.argument_context('sql server tde-key') as c:
        c.argument('server_name', arg_type=server_param_type)

    with self.argument_context('sql server tde-key set') as c:
        c.argument(
            'kid',
            options_list=['--kid', '-k'],
            help=
            'The Azure Key Vault key identifier of the server key to be made encryption protector.'
            'An example key identifier is '
            '"https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901"'
        )

        c.argument('server_key_type',
                   options_list=['--server-key-type', '-t'],
                   help='The type of the server key',
                   arg_type=get_enum_type(ServerKeyType))

    #####
    #           sql server vnet-rule
    #####
    with self.argument_context('sql server vnet-rule') as c:
        # Help text needs to be specified because 'sql server vnet-rule create' is a custom
        # command.
        c.argument('server_name', arg_type=server_param_type)

        c.argument('virtual_network_rule_name', options_list=['--name', '-n'])

        c.argument(
            'virtual_network_subnet_id',
            options_list=['--subnet'],
            help=
            'Name or ID of the subnet that allows access to an Azure Sql 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 firewall rule before the virtual network has vnet service endpoint enabled',
            arg_type=get_three_state_flag())

    with self.argument_context('sql server vnet-rule create') as c:
        c.extra('vnet_name',
                options_list=['--vnet-name'],
                help='The virtual network name')

    ###############################################
    #                sql managed instance         #
    ###############################################
    with self.argument_context('sql mi') as c:
        c.argument(
            'managed_instance_name',
            help='The managed instance name',
            options_list=['--name', '-n'],
            # Allow --ids command line argument. id_part=name is 1st name in uri
            id_part='name')

        c.argument(
            'tier',
            arg_type=tier_param_type,
            help=
            'The edition component of the sku. Allowed value is GeneralPurpose.'
        )

        c.argument('family',
                   arg_type=family_param_type,
                   help='The compute generation component of the sku. '
                   'Allowed values include: Gen4, Gen5.')

        c.argument('storage_size_in_gb',
                   options_list=['--storage'],
                   arg_type=storage_param_type,
                   help='The storage size of the managed instance. '
                   'Storage size must be specified in increments of 32 GB')

        c.argument('license_type',
                   arg_type=get_enum_type(DatabaseLicenseType),
                   help='The license type to apply for this managed instance.')

        c.argument('vcores',
                   options_list=['--capacity', '-c'],
                   help='The capacity of the managed instance in vcores.')

    with self.argument_context('sql mi create') as c:
        # Create args that will be used to build up the ManagedInstance object
        create_args_for_complex_type(c, 'parameters', ManagedInstance, [
            'administrator_login', 'administrator_login_password',
            'license_type', 'virtual_network_subnet_id', 'vcores',
            'storage_size_in_gb'
        ])

        # Create args that will be used to build up the Managed Instance's Sku object
        create_args_for_complex_type(c, 'sku', Sku, [
            'family',
            'name',
            'tier',
        ])

        c.ignore('name')  # Hide sku name

        c.argument('administrator_login',
                   options_list=['--admin-user', '-u'],
                   required=True)

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'],
                   required=True)

        c.extra('vnet_name',
                options_list=['--vnet-name'],
                help='The virtual network name',
                validator=validate_subnet)

        c.argument(
            'virtual_network_subnet_id',
            options_list=['--subnet'],
            required=True,
            help=
            'Name or ID of the subnet that allows access to an Azure Sql Managed Instance. '
            'If subnet name is provided, --vnet-name must be provided.')

        c.argument(
            'assign_identity',
            options_list=['--assign-identity', '-i'],
            help=
            'Generate and assign an Azure Active Directory Identity for this managed instance '
            'for use with key management services like Azure KeyVault.')

    with self.argument_context('sql mi update') as c:
        # Create args that will be used to build up the ManagedInstance object
        create_args_for_complex_type(c, 'parameters', ManagedInstance, [
            'administrator_login_password',
        ])

        c.argument('administrator_login_password',
                   options_list=['--admin-password', '-p'])

        c.argument(
            'assign_identity',
            options_list=['--assign-identity', '-i'],
            help=
            'Generate and assign an Azure Active Directory Identity for this managed instance '
            'for use with key management services like Azure KeyVault. '
            'If identity is already assigned - do nothing.')

    ###############################################
    #                sql managed db               #
    ###############################################
    with self.argument_context('sql midb') as c:
        c.argument(
            'managed_instance_name',
            arg_type=managed_instance_param_type,
            # Allow --ids command line argument. id_part=name is 1st name in uri
            id_part='name')

        c.argument(
            'database_name',
            options_list=['--name', '-n'],
            help='The name of the Azure SQL Managed Database.',
            # Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri
            id_part='child_name_1')

    with self.argument_context('sql midb create') as c:
        create_args_for_complex_type(c, 'parameters', ManagedDatabase, [
            'collation',
        ])

        c.argument(
            'collation',
            required=False,
            help=
            'The collation of the Azure SQL Managed Database collation to use, '
            'e.g.: SQL_Latin1_General_CP1_CI_AS or Latin1_General_100_CS_AS_SC'
        )

    with self.argument_context('sql midb restore') as c:
        create_args_for_complex_type(c, 'parameters', ManagedDatabase, [
            'target_managed_database_name', 'target_managed_instance_name',
            'restore_point_in_time'
        ])

        c.argument(
            'target_managed_database_name',
            options_list=['--dest-name'],
            required=True,
            help=
            'Name of the managed database that will be created as the restore destination.'
        )

        c.argument(
            'target_managed_instance_name',
            options_list=['--dest-mi'],
            help='Name of the managed instance to restore managed database to. '
            'This can be same managed instance, or another managed instance on same subscription. '
            'When not specified it defaults to source managed instance.')

        c.argument(
            'target_resource_group_name',
            options_list=['--dest-resource-group'],
            help=
            'Name of the resource group of the managed instance to restore managed database to. '
            'When not specified it defaults to source resource group.')

        restore_point_arg_group = 'Restore Point'

        c.argument(
            'restore_point_in_time',
            options_list=['--time', '-t'],
            arg_group=restore_point_arg_group,
            required=True,
            help=
            'The point in time of the source database that will be restored to create the'
            ' new database. Must be greater than or equal to the source database\'s'
            ' earliestRestoreDate value. Time should be in following format: "YYYY-MM-DDTHH:MM:SS"'
        )

    with self.argument_context('sql midb list') as c:
        c.argument('managed_instance_name', id_part=None)
示例#44
0
def load_arguments(self, _):

    (IpsecEncryption, IpsecIntegrity, IkeEncryption, IkeIntegrity, DhGroup,
     PfsGroup, VirtualNetworkGatewayConnectionProtocol) = self.get_models(
         'IpsecEncryption', 'IpsecIntegrity', 'IkeEncryption', 'IkeIntegrity',
         'DhGroup', 'PfsGroup', 'VirtualNetworkGatewayConnectionProtocol')

    # region VirtualWAN
    vwan_name_type = CLIArgumentType(
        options_list='--vwan-name',
        metavar='NAME',
        help='Name of the virtual WAN.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/virtualWANs'))
    vhub_name_type = CLIArgumentType(
        options_list='--vhub-name',
        metavar='NAME',
        help='Name of the virtual hub.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/networkHubs'))
    vpn_gateway_name_type = CLIArgumentType(
        options_list='--gateway-name',
        metavar='NAME',
        help='Name of the VPN gateway.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/vpnGateways'))
    vpn_site_name_type = CLIArgumentType(
        options_list='--site-name',
        metavar='NAME',
        help='Name of the VPN site config.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/vpnSites'))

    with self.argument_context('network') as c:
        c.argument('tags', tags_type)

    with self.argument_context('network vwan') as c:
        c.argument('virtual_wan_name',
                   vwan_name_type,
                   options_list=['--name', '-n'])
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('branch_to_branch_traffic',
                   arg_type=get_three_state_flag(),
                   help='Allow branch-to-branch traffic flow.')
        c.argument('vnet_to_vnet_traffic',
                   arg_type=get_three_state_flag(),
                   help='Allow VNet-to-VNet traffic flow.')
        c.argument('security_provider_name',
                   help='The security provider name.')
        c.argument('office365_category',
                   help='The office local breakout category.')
        c.argument('disable_vpn_encryption',
                   arg_type=get_three_state_flag(),
                   help='State of VPN encryption.')
        c.argument('vwan_type',
                   options_list='--type',
                   arg_type=get_enum_type(['Basic', 'Standard']),
                   help='The type of the VirtualWAN.')
    # endregion

    # region VirtualHub
    with self.argument_context('network vhub') as c:
        c.argument('virtual_hub_name',
                   vhub_name_type,
                   options_list=['--name', '-n'])
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('virtual_wan',
                   options_list='--vwan',
                   help='Name or ID of the virtual WAN.',
                   validator=get_network_resource_name_or_id(
                       'virtual_wan', 'virtualWans'))
        c.argument('address_prefix',
                   help='CIDR address prefix for the virtual hub.')
        c.argument('sku',
                   arg_type=get_enum_type(['Basic', 'Standard']),
                   help='The sku of the VirtualHub.')

    with self.argument_context('network vhub', arg_group='Gateway') as c:
        c.argument('express_route_gateway',
                   help='Name or ID of an ExpressRoute gateway.',
                   validator=get_network_resource_name_or_id(
                       'express_route_gateway', 'expressRouteGateways'))
        c.argument('p2s_vpn_gateway',
                   help='Name or ID of a P2S VPN gateway.',
                   validator=get_network_resource_name_or_id(
                       'p2s_vpn_gateway', 'P2sVpnGateways'))
        c.argument('vpn_gateway',
                   help='Name or ID of a VPN gateway.',
                   validator=get_network_resource_name_or_id(
                       'vpn_gateway', 'vpnGateways'))

    with self.argument_context('network vhub connection') as c:
        for dest in ['virtual_hub_name', 'resource_name']:
            c.argument(dest, vhub_name_type)
        for dest in ['item_name', 'connection_name']:
            c.argument(dest,
                       help='Name of the connection.',
                       options_list=['--name', '-n'],
                       id_part='child_name_1')
        c.argument('remote_virtual_network',
                   options_list='--remote-vnet',
                   help='Name of ID of the remote VNet to connect to.',
                   validator=get_network_resource_name_or_id(
                       'remote_virtual_network', 'virtualNetworks'))
        c.argument('allow_hub_to_remote_vnet_transit',
                   arg_type=get_three_state_flag(),
                   options_list='--remote-vnet-transit',
                   help='Enable hub to remote VNet transit.')
        c.argument('allow_remote_vnet_to_use_hub_vnet_gateways',
                   arg_type=get_three_state_flag(),
                   options_list='--use-hub-vnet-gateways',
                   help='Allow remote VNet to use hub\'s VNet gateways.')
        c.argument('enable_internet_security',
                   arg_type=get_three_state_flag(),
                   options_list='--internet-security',
                   help='Enable internet security.')

    with self.argument_context('network vhub connection list') as c:
        c.argument('resource_name', vhub_name_type, id_part=None)

    with self.argument_context('network vhub route') as c:
        c.argument('virtual_hub_name', vhub_name_type, id_part=None)
        c.argument('address_prefixes',
                   nargs='+',
                   help='Space-separated list of CIDR prefixes.')
        c.argument('next_hop_ip_address',
                   options_list='--next-hop',
                   help='IP address of the next hop.')
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')

    with self.argument_context('network vhub route-table') as c:
        c.argument('virtual_hub_name', vhub_name_type, id_part=None)
        c.argument('route_table_name',
                   options_list=['--name', '-n'],
                   help='Name of the virtual hub route table.')
        c.argument('attached_connections',
                   options_list='--connections',
                   nargs='+',
                   arg_type=get_enum_type(['All_Vnets', 'All_Branches']),
                   help='List of all connections attached to this route table')
        c.argument('destination_type',
                   arg_type=get_enum_type(['Service', 'CIDR']),
                   help='The type of destinations')
        c.argument('destinations',
                   nargs='+',
                   help='Space-separated list of all destinations.')
        c.argument(
            'next_hop_type',
            arg_type=get_enum_type(['IPAddress']),
            help='The type of next hops. Currently it only supports IP Address.'
        )
        c.argument('next_hops',
                   nargs='+',
                   help='Space-separated list of IP address of the next hop.')
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')
    # endregion

    # region VpnGateways
    with self.argument_context('network vpn-gateway') as c:
        c.argument('virtual_hub',
                   options_list='--vhub',
                   help='Name or ID of a virtual hub.',
                   validator=get_network_resource_name_or_id(
                       'virtual_hub', 'virtualHubs'))
        c.argument('scale_unit',
                   type=int,
                   help='The scale unit for this VPN gateway.')
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('gateway_name',
                   vpn_gateway_name_type,
                   options_list=['--name', '-n'])

    with self.argument_context('network vpn-gateway connection') as c:
        for dest in ['gateway_name', 'resource_name']:
            c.argument(dest, vpn_gateway_name_type)
        for dest in ['item_name', 'connection_name']:
            c.argument(dest,
                       help='Name of the VPN gateway connection.',
                       options_list=['--name', '-n'],
                       id_part='child_name_1')
        c.argument('remote_vpn_site',
                   help='Name of ID of the remote VPN site.',
                   validator=get_network_resource_name_or_id(
                       'remote_vpn_site', 'vpnSites'))
        c.argument('connection_bandwidth',
                   help='Expected bandwidth in Mbps.',
                   type=int)
        c.argument('enable_bgp',
                   arg_type=get_three_state_flag(),
                   help='Enable BGP.')
        c.argument('enable_internet_security',
                   options_list='--internet-security',
                   arg_type=get_three_state_flag(),
                   help='Enable internet security.')
        c.argument('enable_rate_limiting',
                   options_list='--rate-limiting',
                   arg_type=get_three_state_flag(),
                   help='Enable rate limiting.')
        c.argument(
            'protocol_type',
            arg_type=get_enum_type(VirtualNetworkGatewayConnectionProtocol),
            help='Connection protocol.')
        c.argument('routing_weight', type=int, help='Routing weight.')
        c.argument('shared_key', help='Shared key.')

    with self.argument_context('network vpn-gateway connection list') as c:
        c.argument('resource_name', vpn_gateway_name_type, id_part=None)

    with self.argument_context('network vpn-gateway connection',
                               arg_group='IP Security') as c:
        c.argument(
            'sa_life_time_seconds',
            options_list='--sa-lifetime',
            help=
            'IPSec Security Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for a site-to-site VPN tunnel.',
            type=int)
        c.argument(
            'sa_data_size_kilobytes',
            options_list='--sa-data-size',
            help=
            'IPSec Security Association (also called Quick Mode or Phase 2 SA) payload size in KB for a site-to-site VPN tunnel.',
            type=int)
        c.argument('ipsec_encryption',
                   arg_type=get_enum_type(IpsecEncryption),
                   help='IPSec encryption algorithm (IKE phase 1).')
        c.argument('ipsec_integrity',
                   arg_type=get_enum_type(IpsecIntegrity),
                   help='IPSec integrity algorithm (IKE phase 1).')
        c.argument('ike_encryption',
                   arg_type=get_enum_type(IkeEncryption),
                   help='IKE encryption algorithm (IKE phase 2).')
        c.argument('ike_integrity',
                   arg_type=get_enum_type(IkeIntegrity),
                   help='IKE integrity algorithm (IKE phase 2).')
        c.argument('dh_group',
                   arg_type=get_enum_type(DhGroup),
                   help='DH Groups used in IKE Phase 1 for initial SA.')
        c.argument('pfs_group',
                   arg_type=get_enum_type(PfsGroup),
                   help='The Pfs Groups used in IKE Phase 2 for new child SA.')

    with self.argument_context(
            'network vpn-gateway connection ipsec-policy') as c:
        c.argument('gateway_name', vpn_gateway_name_type, id_part=None)
        c.argument('connection_name',
                   options_list='--connection-name',
                   help='Name of the VPN gateway connection.')
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')
    # endregion

    # region VpnSites
    with self.argument_context('network vpn-site') as c:
        c.argument('vpn_site_name',
                   vpn_site_name_type,
                   options_list=['--name', '-n'])
        c.argument('virtual_wan',
                   help='Name or ID of the virtual WAN.',
                   validator=get_network_resource_name_or_id(
                       'virtual_wan', 'virtualWans'))
        c.argument('is_security_site',
                   arg_type=get_three_state_flag(),
                   options_list='--security-site',
                   help='Whether the VPN site is security-related.')
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('ip_address', help='IP address of the VPN site.')
        c.argument(
            'site_key',
            help='Key for the VPN site that can be used for connections.')
        c.argument('address_prefixes',
                   nargs='+',
                   help='Space-separated list of CIDR address prefixes.')

    with self.argument_context('network vpn-site',
                               arg_group='Device Property') as c:
        c.argument('device_model', help='Model of the device.')
        c.argument('device_vendor', help='Name of the device vendor.')
        c.argument('link_speed', help='Link speed in Mbps.', type=int)

    for scope in ['vpn-site', 'vpn-gateway']:
        with self.argument_context('network {}'.format(scope),
                                   arg_group='BGP Peering') as c:
            c.argument('asn', help='BGP speaker\'s ASN.', type=int)
            c.argument(
                'peer_weight',
                help='Weight added to routes learned from this BGP speaker.',
                type=int)
            c.argument(
                'bgp_peering_address',
                help='Peering address and BGP identifier of this BGP speaker.')

    with self.argument_context('network vpn-site download') as c:
        c.argument('virtual_wan_name', vwan_name_type, id_part=None)
        c.argument('vpn_sites',
                   help='Space-separated list of VPN site names or IDs.',
                   nargs='+',
                   validator=get_network_resource_name_or_id(
                       'vpn_sites', 'vpnSites'))
示例#45
0
def load_arguments(self, _):

    with self.argument_context('connectedmachine machine list') as c:
        c.argument('resource_group_name', resource_group_name_type)

    with self.argument_context('connectedmachine machine show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', options_list=['--name', '-n', '--machine-name'], type=str, help='The name of the '
                   'hybrid machine.', id_part='name')

    with self.argument_context('connectedmachine machine delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', options_list=['--name', '-n', '--machine-name'], type=str, help='The name of the '
                   'hybrid machine.', id_part='name')

    with self.argument_context('connectedmachine machine-extension list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', type=str, help='The name of the machine containing the extension.')
        c.argument('expand', type=str, help='The expand expression to apply on the operation.')

    with self.argument_context('connectedmachine machine-extension show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', type=str, help='The name of the machine containing the extension.', id_part='name')
        c.argument('name', options_list=['--name', '-n', '--extension-name'], type=str, help='The name of the machine extension.', id_part='child_name_1')

    with self.argument_context('connectedmachine machine-extension create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', type=str, help='The name of the machine where the extension should be created or '
                   'updated.')
        c.argument('name', options_list=['--name', '-n', '--extension-name'], type=str, help='The name of the machine extension.')
        c.argument('tags', tags_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('force_update_tag', type=str, help='How the extension handler should be forced to update even if '
                   'the extension configuration has not changed.')
        c.argument('publisher', type=str, help='The name of the extension handler publisher.')
        c.argument('type_', options_list=['--type'], type=str, help='Specifies the type of the extension; an example '
                   'is "CustomScriptExtension".')
        c.argument('type_handler_version', type=str, help='Specifies the version of the script handler.')
        c.argument('auto_upgrade_minor_version', options_list=['--auto-upgrade-minor'],
                   arg_type=get_three_state_flag(), help='Indicates whether the extension should use a newer minor '
                   'version if one is available at deployment time. Once deployed, however, the extension will not '
                   'upgrade minor versions unless redeployed, even with this property set to true.')
        c.argument('settings', type=validate_file_or_dict, help='Json formatted public settings for the extension. '
                   'Expected value: json-string/@json-file.')
        c.argument('protected_settings', type=validate_file_or_dict, help='The extension can contain either '
                   'protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. Expected '
                   'value: json-string/@json-file.')

    with self.argument_context('connectedmachine machine-extension update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', type=str, help='The name of the machine where the extension should be created or '
                   'updated.', id_part='name')
        c.argument('name', options_list=['--name', '-n', '--extension-name'], type=str, help='The name of the machine extension.', id_part='child_name_1')
        c.argument('tags', tags_type)
        c.argument('force_update_tag', type=str, help='How the extension handler should be forced to update even if '
                   'the extension configuration has not changed.')
        c.argument('publisher', type=str, help='The name of the extension handler publisher.')
        c.argument('type_', options_list=['--type'], type=str, help='Specifies the type of the extension; an example '
                   'is "CustomScriptExtension".')
        c.argument('type_handler_version', type=str, help='Specifies the version of the script handler.')
        c.argument('auto_upgrade_minor_version', options_list=['--auto-upgrade-minor'],
                   arg_type=get_three_state_flag(), help='Indicates whether the extension should use a newer minor '
                   'version if one is available at deployment time. Once deployed, however, the extension will not '
                   'upgrade minor versions unless redeployed, even with this property set to true.')
        c.argument('settings', type=validate_file_or_dict, help='Json formatted public settings for the extension. '
                   'Expected value: json-string/@json-file.')
        c.argument('protected_settings', type=validate_file_or_dict, help='The extension can contain either '
                   'protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. Expected '
                   'value: json-string/@json-file.')

    with self.argument_context('connectedmachine machine-extension delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', type=str, help='The name of the machine where the extension should be deleted.',
                   id_part='name')
        c.argument('name', options_list=['--name', '-n', '--extension-name'], type=str, help='The name of the machine extension.', id_part='child_name_1')

    with self.argument_context('connectedmachine machine-extension wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('machine_name', type=str, help='The name of the machine containing the extension.', id_part='name')
        c.argument('name', options_list=['--name', '-n', '--extension-name'], type=str, help='The name of the machine extension.', id_part='child_name_1')
示例#46
0
def load_arguments(self, _):

    from azure.cli.core.commands.parameters import tags_type
    from azure.cli.core.commands.validators import get_default_location_from_resource_group

    with self.argument_context('apim') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('tags', tags_type)
        c.argument('service_name',
                   options_list=['--name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument('name',
                   options_list=['--name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument('location',
                   validator=get_default_location_from_resource_group)

    with self.argument_context('apim create') as c:
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument(
            'publisher_name',
            help=
            'The name of your organization for use in the developer portal and e-mail notifications.'
        )
        c.argument(
            'publisher_email',
            help='The e-mail address to receive all system notifications.')
        c.argument(
            'enable_client_certificate',
            arg_type=get_three_state_flag(),
            help=
            'Enforces a client certificate to be presented on each request to the gateway and also enables the ability to authenticate the certificate in the policy on the gateway.'
        )
        c.argument('virtual_network_type',
                   get_enum_type(VNET_TYPES),
                   options_list=['--virtual-network', '-v'],
                   help='The virtual network type.')
        c.argument('sku_name',
                   arg_type=get_enum_type(SKU_TYPES),
                   help='The sku of the api management instance')
        c.argument('sku_capacity',
                   type=int,
                   help='The number of deployed units of the SKU.')
        c.argument(
            'enable_managed_identity',
            arg_type=get_three_state_flag(),
            help=
            'Create a managed identity for the API Management service to access other Azure resources.'
        )

    with self.argument_context('apim update') as c:
        c.argument(
            'publisher_name',
            help=
            'The name of your organization for use in the developer portal and e-mail notifications.'
        )
        c.argument(
            'publisher_email',
            help='The e-mail address to receive all system notifications.')
        c.argument(
            'enable_client_certificate',
            arg_type=get_three_state_flag(),
            help=
            'Enforces a client certificate to be presented on each request to the gateway and also enables the ability to authenticate the certificate in the policy on the gateway.'
        )
        c.argument('virtual_network_type',
                   get_enum_type(VNET_TYPES),
                   options_list=['--virtual-network', '-v'],
                   help='The virtual network type.')
        c.argument('sku_name',
                   arg_type=get_enum_type(SKU_TYPES),
                   help='The sku of the api management instance')
        c.argument('sku_capacity',
                   type=int,
                   help='The number of deployed units of the SKU.')
        c.argument(
            'enable_managed_identity',
            arg_type=get_three_state_flag(),
            help=
            'Create a managed identity for the API Management service to access other Azure resources.'
        )
示例#47
0
def load_arguments(self, _):

    with self.argument_context('healthcareapis service list') as c:
        c.argument('resource_group_name', resource_group_name_type)

    with self.argument_context('healthcareapis service show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')

    with self.argument_context('healthcareapis service create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.')
        c.argument('kind', arg_type=get_enum_type(['fhir', 'fhir-Stu3', 'fhir-R4']), help='The kind of the service.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('identity_type', arg_type=get_enum_type(['SystemAssigned', 'None']), help='Type of identity being '
                   'specified, currently SystemAssigned and None are allowed.')
        c.argument('access_policies', action=AddAccessPolicies, nargs='*', help='The access policies of the service '
                   'instance.')
        c.argument('cosmos_db_configuration', action=AddCosmosDbConfiguration, nargs='*', help='The settings for the '
                   'Cosmos DB database backing the service.')
        c.argument('authentication_configuration', options_list=['--authentication-configuration', '-c'],
                   action=AddAuthenticationConfiguration, nargs='*',
                   help='The authentication configuration for the service instance.')
        c.argument('cors_configuration', action=AddCorsConfiguration, nargs='*', help='The settings for the CORS '
                   'configuration of the service instance.')
        c.argument('private_endpoint_connections', action=AddPrivateEndpointConnections, nargs='*', help='The list of '
                   'private endpoint connections that are set up for this resource.')
        c.argument('public_network_access', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Control permission '
                   'for data plane traffic coming from public networks while private endpoint is enabled.')
        c.argument('login_servers', type=str, help='The list of login servers that shall'
                   'be added to the service instance.', arg_group='Acr Configuration')
        c.argument('oci_artifacts',
                   action=AddServicesOciArtifacts, nargs='*',
                   help='The list of Open Container Initiative (OCI) artifacts.', arg_group='Acr Configuration')
        c.argument('export_configuration_storage_account_name',
                   options_list=['--export-configuration-storage-account-name', '-s'],
                   type=str, help='The name of the default export storage '
                   'account.')

    with self.argument_context('healthcareapis service update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('tags', tags_type)
        c.argument('public_network_access', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Control permission '
                   'for data plane traffic coming from public networks while private endpoint is enabled.')

    with self.argument_context('healthcareapis service delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')

    with self.argument_context('healthcareapis service wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')

    with self.argument_context('healthcareapis operation-result show') as c:
        c.argument('location_name', type=str, help='The location of the operation.', id_part='name')
        c.argument('operation_result_id', type=str, help='The ID of the operation result to get.',
                   id_part='child_name_1')

    with self.argument_context('healthcareapis private-endpoint-connection list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.')

    with self.argument_context('healthcareapis private-endpoint-connection show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection associated with the Azure resource',
                   id_part='child_name_1')

    with self.argument_context('healthcareapis private-endpoint-connection create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection associated with the Azure resource')
        c.argument('private_link_service_connection_state',
                   options_list=['--private-link-service-connection-state', '-s'],
                   action=AddPrivateLinkServiceConnectionState, nargs='*',
                   help='A collection of information about the state of the connection between service consumer and '
                   'provider.')
        c.argument('private_link_service_connection_state_status',
                   arg_type=get_enum_type(['Pending', 'Approved', 'Rejected']),
                   help='Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.',
                   deprecate_info=c.deprecate(redirect='--private-link-service-connection-state'))
        c.argument('private_link_service_connection_state_description', type=str,
                   help='The reason for approval/rejection of the connection.',
                   deprecate_info=c.deprecate(redirect='--private-link-service-connection-state'))
        c.argument('private_link_service_connection_state_actions_required', type=str, help='A message indicating if '
                   'changes on the service provider require any updates on the consumer.',
                   deprecate_info=c.deprecate(redirect='--private-link-service-connection-state'))

    with self.argument_context('healthcareapis private-endpoint-connection update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection associated with the Azure resource',
                   id_part='child_name_1')
        c.argument('private_link_service_connection_state',
                   options_list=['--private-link-service-connection-state', '-s'],
                   action=AddPrivateLinkServiceConnectionState, nargs='*',
                   help='A collection of information about the state of the connection between service consumer and '
                   'provider.')
        c.argument('private_link_service_connection_state_status',
                   arg_type=get_enum_type(['Pending', 'Approved', 'Rejected']),
                   help='Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.',
                   deprecate_info=c.deprecate(redirect='--private-link-service-connection-state'))
        c.argument('private_link_service_connection_state_description', type=str,
                   help='The reason for approval/rejection of the connection.',
                   deprecate_info=c.deprecate(redirect='--private-link-service-connection-state'))
        c.argument('private_link_service_connection_state_actions_required', type=str, help='A message indicating if '
                   'changes on the service provider require any updates on the consumer.',
                   deprecate_info=c.deprecate(redirect='--private-link-service-connection-state'))

    with self.argument_context('healthcareapis private-endpoint-connection delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection associated with the Azure resource',
                   id_part='child_name_1')

    with self.argument_context('healthcareapis private-endpoint-connection wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'], type=str,
                   help='The name of the private endpoint connection associated with the Azure resource',
                   id_part='child_name_1')

    with self.argument_context('healthcareapis private-link-resource list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.')

    with self.argument_context('healthcareapis private-link-resource show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('group_name', type=str, help='The name of the private link resource group.',
                   id_part='child_name_1')

    with self.argument_context('healthcareapis acr list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.')

    with self.argument_context('healthcareapis acr add') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('login_servers', type=str, help='The list of login servers that shall'
                   'be added to the service instance.')

    with self.argument_context('healthcareapis acr remove') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('login_servers', type=str, help='The list of login servers that shall'
                   'be removed from the service instance.')

    with self.argument_context('healthcareapis acr reset') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('resource_name', type=str, help='The name of the service instance.', id_part='name')
        c.argument('login_servers', type=str, help='The list of login servers to substitute for the existing one.')

    with self.argument_context('healthcareapis workspace list') as c:
        c.argument('resource_group_name', resource_group_name_type)

    with self.argument_context('healthcareapis workspace show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', options_list=['--name', '-n', '--workspace-name'], type=str, help='The name of '
                   'workspace resource.', id_part='name')

    with self.argument_context('healthcareapis workspace create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', options_list=['--name', '-n', '--workspace-name'], type=str, help='The name of '
                   'workspace resource.')
        c.argument('tags', tags_type)
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('public_network_access', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Control permission '
                   'for data plane traffic coming from public networks while private endpoint is enabled.')

    with self.argument_context('healthcareapis workspace update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', options_list=['--name', '-n', '--workspace-name'], type=str, help='The name of '
                   'workspace resource.', id_part='name')
        c.argument('tags', tags_type)

    with self.argument_context('healthcareapis workspace delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', options_list=['--name', '-n', '--workspace-name'], type=str, help='The name of '
                   'workspace resource.', id_part='name')

    with self.argument_context('healthcareapis workspace wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', options_list=['--name', '-n', '--workspace-name'], type=str, help='The name of '
                   'workspace resource.', id_part='name')

    with self.argument_context('healthcareapis workspace dicom-service list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')

    with self.argument_context('healthcareapis workspace dicom-service show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('dicom_service_name', options_list=['--name', '-n', '--dicom-service-name'], type=str, help='The '
                   'name of DICOM Service resource.', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace dicom-service create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')
        c.argument('dicom_service_name', options_list=['--name', '-n', '--dicom-service-name'], type=str, help='The '
                   'name of DICOM Service resource.')
        c.argument('tags', tags_type)
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('identity_type',
                   arg_type=get_enum_type(['None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned']),
                   help='Type of identity being specified, currently SystemAssigned and None are allowed.',
                   arg_group='Identity')
        c.argument('user_assigned_identities', options_list=['--user-assigned-identities', '-i'],
                   type=validate_file_or_dict, help='The set of user assigned identities '
                   'associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids '
                   'in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microso'
                   'ft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty '
                   'objects ({}) in requests. Expected value: json-string/json-file/@json-file.',
                   arg_group='Identity')
        c.argument('public_network_access', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Control permission '
                   'for data plane traffic coming from public networks while private endpoint is enabled.')

    with self.argument_context('healthcareapis workspace dicom-service update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('dicom_service_name', options_list=['--name', '-n', '--dicom-service-name'], type=str, help='The '
                   'name of DICOM Service resource.', id_part='child_name_1')
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('tags', tags_type)
        c.argument('identity_type',
                   arg_type=get_enum_type(['None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned']),
                   help='Type of identity being specified, currently SystemAssigned and None are allowed.',
                   arg_group='Identity')
        c.argument('user_assigned_identities', options_list=['--user-assigned-identities', '-i'],
                   type=validate_file_or_dict, help='The set of user assigned identities '
                   'associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids '
                   'in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microso'
                   'ft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty '
                   'objects ({}) in requests. Expected value: json-string/json-file/@json-file.',
                   arg_group='Identity')

    with self.argument_context('healthcareapis workspace dicom-service delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('dicom_service_name', options_list=['--name', '-n', '--dicom-service-name'], type=str, help='The '
                   'name of DICOM Service resource.', id_part='child_name_1')
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')

    with self.argument_context('healthcareapis workspace dicom-service wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('dicom_service_name', options_list=['--name', '-n', '--dicom-service-name'], type=str, help='The '
                   'name of DICOM Service resource.', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace iot-connector list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')

    with self.argument_context('healthcareapis workspace iot-connector show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('iot_connector_name', options_list=['--name', '-n', '--iot-connector-name'], type=str, help='The '
                   'name of IoT Connector resource.', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace iot-connector create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')
        c.argument('iot_connector_name', options_list=['--name', '-n', '--iot-connector-name'], type=str, help='The '
                   'name of IoT Connector resource.')
        c.argument('tags', tags_type)
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('identity_type',
                   arg_type=get_enum_type(['None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned']),
                   help='Type of identity being specified, currently SystemAssigned and None are allowed.',
                   arg_group='Identity')
        c.argument('user_assigned_identities', options_list=['--user-assigned-identities', '-i'],
                   type=validate_file_or_dict, help='The set of user assigned identities '
                   'associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids '
                   'in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microso'
                   'ft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty '
                   'objects ({}) in requests. Expected value: json-string/json-file/@json-file.',
                   arg_group='Identity')
        c.argument('ingestion_endpoint_configuration',
                   options_list=['--ingestion-endpoint-configuration', '-c'],
                   action=AddIngestionEndpointConfiguration, nargs='*', help='Source configuration.')
        c.argument('content', type=validate_file_or_dict, help='The mapping. Expected value: '
                   'json-string/json-file/@json-file.', arg_group='Device Mapping')

    with self.argument_context('healthcareapis workspace iot-connector update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('iot_connector_name', options_list=['--name', '-n', '--iot-connector-name'], type=str, help='The '
                   'name of IoT Connector resource.', id_part='child_name_1')
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('tags', tags_type)
        c.argument('identity_type',
                   arg_type=get_enum_type(['None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned']),
                   help='Type of identity being specified, currently SystemAssigned and None are allowed.',
                   arg_group='Identity')
        c.argument('user_assigned_identities', options_list=['--user-assigned-identities', '-i'],
                   type=validate_file_or_dict, help='The set of user assigned identities '
                   'associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids '
                   'in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microso'
                   'ft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty '
                   'objects ({}) in requests. Expected value: json-string/json-file/@json-file.',
                   arg_group='Identity')

    with self.argument_context('healthcareapis workspace iot-connector delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('iot_connector_name', options_list=['--name', '-n', '--iot-connector-name'], type=str, help='The '
                   'name of IoT Connector resource.', id_part='child_name_1')
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')

    with self.argument_context('healthcareapis workspace iot-connector wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('iot_connector_name', options_list=['--name', '-n', '--iot-connector-name'], type=str, help='The '
                   'name of IoT Connector resource.', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace iot-connector fhir-destination list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')
        c.argument('iot_connector_name', type=str, help='The name of IoT Connector resource.')

    with self.argument_context('healthcareapis workspace iot-connector fhir-destination show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('iot_connector_name', type=str, help='The name of IoT Connector resource.', id_part='child_name_1')
        c.argument('fhir_destination_name', type=str, help='The name of IoT Connector FHIR destination resource.',
                   id_part='child_name_2')

    with self.argument_context('healthcareapis workspace iot-connector fhir-destination create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')
        c.argument('iot_connector_name', type=str, help='The name of IoT Connector resource.')
        c.argument('fhir_destination_name', type=str, help='The name of IoT Connector FHIR destination resource.')
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('resource_identity_resolution_type',
                   options_list=['--resource-identity-resolution-type', '-t'],
                   arg_type=get_enum_type(['Create', 'Lookup']),
                   help='Determines how resource identity is resolved on the destination.')
        c.argument('fhir_service_resource_id',
                   options_list=['--fhir-service-resource-id', '-r'],
                   type=str, help='Fully qualified resource id of the FHIR service to connect to.')
        c.argument('content', type=validate_file_or_dict, help='The mapping. Expected value: '
                   'json-string/json-file/@json-file.', arg_group='Fhir Mapping')

    with self.argument_context('healthcareapis workspace iot-connector fhir-destination update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('iot_connector_name', type=str, help='The name of IoT Connector resource.', id_part='child_name_1')
        c.argument('fhir_destination_name', type=str, help='The name of IoT Connector FHIR destination resource.',
                   id_part='child_name_2')
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('resource_identity_resolution_type',
                   options_list=['--resource-identity-resolution-type', '-t'],
                   arg_type=get_enum_type(['Create', 'Lookup']),
                   help='Determines how resource identity is resolved on the destination.')
        c.argument('fhir_service_resource_id',
                   options_list=['--fhir-service-resource-id', '-r'],
                   type=str, help='Fully qualified resource id of the FHIR service to connect to.')
        c.argument('content', type=validate_file_or_dict, help='The mapping. Expected value: '
                   'json-string/json-file/@json-file.', arg_group='Fhir Mapping')
        c.ignore('iot_fhir_destination')

    with self.argument_context('healthcareapis workspace iot-connector fhir-destination delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('iot_connector_name', type=str, help='The name of IoT Connector resource.', id_part='child_name_1')
        c.argument('fhir_destination_name', type=str, help='The name of IoT Connector FHIR destination resource.',
                   id_part='child_name_2')

    with self.argument_context('healthcareapis workspace iot-connector fhir-destination wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('iot_connector_name', type=str, help='The name of IoT Connector resource.', id_part='child_name_1')
        c.argument('fhir_destination_name', type=str, help='The name of IoT Connector FHIR destination resource.',
                   id_part='child_name_2')

    with self.argument_context('healthcareapis workspace fhir-service list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')

    with self.argument_context('healthcareapis workspace fhir-service show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('fhir_service_name', options_list=['--name', '-n', '--fhir-service-name'], type=str, help='The name '
                   'of FHIR Service resource.', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace fhir-service create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')
        c.argument('fhir_service_name', options_list=['--name', '-n', '--fhir-service-name'], type=str, help='The name '
                   'of FHIR Service resource.')
        c.argument('tags', tags_type)
        c.argument('etag', type=str, help='An etag associated with the resource, used for optimistic concurrency when '
                   'editing it.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('identity_type',
                   arg_type=get_enum_type(['None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned']),
                   help='Type of identity being specified, currently SystemAssigned and None are allowed.',
                   arg_group='Identity')
        c.argument('user_assigned_identities', options_list=['--user-assigned-identities', '-i'],
                   type=validate_file_or_dict, help='The set of user assigned identities '
                   'associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids '
                   'in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microso'
                   'ft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty '
                   'objects ({}) in requests. Expected value: json-string/json-file/@json-file.',
                   arg_group='Identity')
        c.argument('kind', arg_type=get_enum_type(['fhir-Stu3', 'fhir-R4']), help='The kind of the service.')
        c.argument('access_policies', action=AddFhirservicesAccessPolicies, nargs='*', help='Fhir Service access '
                   'policies.')
        c.argument('authentication_configuration', options_list=['--authentication-configuration', '-c'],
                   action=AddFhirservicesAuthenticationConfiguration, nargs='*',
                   help='Fhir Service authentication configuration.')
        c.argument('cors_configuration', action=AddFhirservicesCorsConfiguration, nargs='*', help='Fhir Service Cors '
                   'configuration.')
        c.argument('public_network_access', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Control permission '
                   'for data plane traffic coming from public networks while private endpoint is enabled.')
        c.argument('default', arg_type=get_enum_type(['no-version', 'versioned', 'versioned-update']), help='The '
                   'default value for tracking history across all resources.', arg_group='Resource Version Policy '
                   'Configuration')
        c.argument('resource_type_overrides', options_list=['--resource-type-overrides', '-r'],
                   action=AddResourceTypeOverrides, nargs='*', help='A list of FHIR '
                   'Resources and their version policy overrides. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...',
                   arg_group='Resource Version Policy Configuration')
        c.argument('export_configuration_storage_account_name',
                   options_list=['--export-configuration-storage-account-name', '-s'],
                   type=str, help='The name of the default export storage account.',
                   arg_group='Export Configuration')
        c.argument('login_servers', nargs='*', help='The list of the Azure container registry login servers.',
                   arg_group='Acr Configuration')
        c.argument('oci_artifacts', action=AddFhirservicesOciArtifacts, nargs='*', help='The list of Open Container '
                   'Initiative (OCI) artifacts.', arg_group='Acr Configuration')

    with self.argument_context('healthcareapis workspace fhir-service update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('fhir_service_name', options_list=['--name', '-n', '--fhir-service-name'], type=str, help='The name '
                   'of FHIR Service resource.', id_part='child_name_1')
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('tags', tags_type)
        c.argument('identity_type',
                   arg_type=get_enum_type(['None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned']),
                   help='Type of identity being specified, currently SystemAssigned and None are allowed.',
                   arg_group='Identity')
        c.argument('user_assigned_identities', options_list=['--user-assigned-identities', '-i'],
                   type=validate_file_or_dict, help='The set of user assigned identities '
                   'associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids '
                   'in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microso'
                   'ft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty '
                   'objects ({}) in requests. Expected value: json-string/json-file/@json-file.',
                   arg_group='Identity')

    with self.argument_context('healthcareapis workspace fhir-service delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('fhir_service_name', options_list=['--name', '-n', '--fhir-service-name'], type=str, help='The name '
                   'of FHIR Service resource.', id_part='child_name_1')
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')

    with self.argument_context('healthcareapis workspace fhir-service wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('fhir_service_name', options_list=['--name', '-n', '--fhir-service-name'], type=str, help='The name '
                   'of FHIR Service resource.', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace private-endpoint-connection list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')

    with self.argument_context('healthcareapis workspace private-endpoint-connection show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection '
                   'associated with the Azure resource', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace private-endpoint-connection create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection '
                   'associated with the Azure resource')
        c.argument('private_link_service_connection_state',
                   options_list=['--private-link-service-connection-state', '-s'],
                   action=AddPrivateLinkServiceConnectionState, nargs='*',
                   help='A collection of information about the state of the connection between service consumer and '
                   'provider.')

    with self.argument_context('healthcareapis workspace private-endpoint-connection update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection '
                   'associated with the Azure resource', id_part='child_name_1')
        c.argument('private_link_service_connection_state',
                   options_list=['--private-link-service-connection-state', '-s'],
                   action=AddPrivateLinkServiceConnectionState, nargs='*',
                   help='A collection of information about the state of the connection between service consumer and '
                   'provider.')
        c.ignore('properties')

    with self.argument_context('healthcareapis workspace private-endpoint-connection delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection '
                   'associated with the Azure resource', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace private-endpoint-connection wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('private_endpoint_connection_name',
                   options_list=['--name', '-n', '--private-endpoint-connection-name'],
                   type=str, help='The name of the private endpoint connection '
                   'associated with the Azure resource', id_part='child_name_1')

    with self.argument_context('healthcareapis workspace private-link-resource list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.')

    with self.argument_context('healthcareapis workspace private-link-resource show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('workspace_name', type=str, help='The name of workspace resource.', id_part='name')
        c.argument('group_name', type=str, help='The name of the private link resource group.',
                   id_part='child_name_1')
示例#48
0
def load_arguments(self, _):

    with self.argument_context(
            'monitor data-collection rule association') as c:
        c.argument('resource_uri',
                   options_list=['--resource'],
                   help='The identifier of the resource.')
        c.argument('association_name',
                   options_list=['--name', '-n'],
                   help='The name of the association.')
        c.argument('description', help='Description of the association.')
        c.argument(
            'rule_id',
            help=
            'The resource ID of the data collection rule that is to be associated.'
        )
        c.argument('data_collection_rule_name', options_list=['--rule-name'])

    with self.argument_context(
            'monitor data-collection rule association list') as c:
        c.argument('data_collection_rule_name',
                   options_list=['--rule-name'],
                   id_part=None)

    with self.argument_context('monitor data-collection rule') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('data_collection_rule_name',
                   options_list=['--name', '-n'],
                   help='The name of the data '
                   'collection rule. The name is case insensitive.',
                   id_part='name')
        c.argument('tags', tags_type)
        c.argument('description',
                   help='Description of the data collection rule.')

        c.argument('data_flows',
                   action=AddDataFlows,
                   options_list=['--data-flows'],
                   arg_group="Data Flow",
                   nargs='+',
                   help='The specification of data flows.')

        c.argument('destinations__log_analytics',
                   options_list=['--log-analytics'],
                   arg_group="Destinations",
                   action=AddDestinationsLogAnalytics,
                   nargs='+',
                   help='List of Log Analytics destinations.')
        c.argument('destinations__azure_monitor_metrics',
                   options_list=['--monitor-metrics'],
                   arg_group="Destinations",
                   action=AddDestinationsAzureMonitorMetrics,
                   nargs='+',
                   help='Azure Monitor Metrics destination.')

        c.argument(
            'data_sources__performance_counters',
            options_list=['--performance-counters'],
            arg_group="Data Sources",
            action=AddDataSourcesPerformanceCounters,
            nargs='+',
            help='The list of performance counter data source configurations.')
        c.argument('data_sources__windows_event_logs',
                   options_list=['--windows-event-logs'],
                   arg_group="Data Sources",
                   action=AddDataSourcesWindowsEventLogs,
                   nargs='+',
                   help='The list of Windows Event Log data source '
                   'configurations.')
        c.argument('data_sources__syslog',
                   options_list=['--syslog'],
                   arg_group="Data Sources",
                   action=AddDataSourcesSyslog,
                   nargs='+',
                   help='The list of Syslog data source configurations.')
        c.argument(
            'data_sources__extensions',
            options_list=['--extensions'],
            arg_group="Data Sources",
            type=validate_file_or_dict,
            help='The list of Azure VM extension data source configurations. '
            'Expected value: json-string/@json-file.')

    with self.argument_context('monitor data-collection rule list') as c:
        c.argument('data_collection_rule_name', id_part=None)

    with self.argument_context('monitor data-collection rule create') as c:
        c.argument('data_collection_rule_name', id_part=None)
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   required=False,
                   validator=get_default_location_from_resource_group)

    with self.argument_context('monitor data-collection rule data-flow') as c:
        c.argument('data_collection_rule_name', options_list=['--rule-name'])
        c.argument('streams',
                   options_list=['--streams'],
                   arg_type=get_enum_type(KnownDataFlowStreams),
                   nargs='+',
                   help='List of streams for this data flow.')
        c.argument('destinations',
                   options_list=['--destinations'],
                   nargs='+',
                   help='List of destinations for this data flow.')

    with self.argument_context(
            'monitor data-collection rule data-flow list') as c:
        c.argument('data_collection_rule_name', id_part=None)

    with self.argument_context(
            'monitor data-collection rule log-analytics') as c:
        c.argument('data_collection_rule_name', options_list=['--rule-name'])
        c.argument(
            'name',
            options_list=['--name', '-n'],
            help=
            'A friendly name for the destination. This name should be unique across all destinations '
            '(regardless of type) within the data collection rule.')
        c.argument('workspace_resource_id',
                   options_list=['--resource-id'],
                   help='The resource ID of the Log Analytics workspace.')

    with self.argument_context(
            'monitor data-collection rule log-analytics list') as c:
        c.argument('data_collection_rule_name', id_part=None)

    with self.argument_context(
            'monitor data-collection rule performance-counter') as c:
        c.argument('data_collection_rule_name', options_list=['--rule-name'])
        c.argument(
            'name',
            options_list=['--name', '-n'],
            help=
            'A friendly name for the data source. This name should be unique across all data sources '
            '(regardless of type) within the data collection rule.')
        c.argument(
            'streams',
            options_list=['--streams'],
            arg_type=get_enum_type(KnownPerfCounterDataSourceStreams),
            nargs='+',
            help=
            'List of streams that this data source will be sent to. A stream '
            'indicates what schema will be used for this data and usually what table in Log Analytics the data '
            'will be sent to.')
        c.argument(
            'scheduled_transfer_period',
            options_list=['--transfer-period'],
            arg_type=get_enum_type(
                KnownPerfCounterDataSourceScheduledTransferPeriod),
            help=
            'The interval between data uploads (scheduled transfers), rounded up to the nearest minute.'
        )
        c.argument(
            'sampling_frequency_in_seconds',
            options_list=['--sampling-frequency'],
            type=int,
            help=
            'The number of seconds between consecutive counter measurements (samples).'
        )
        c.argument(
            'counter_specifiers',
            options_list=['--counter-specifiers'],
            nargs='+',
            help=
            "A list of specifier names of the performance counters you want to collect."
            "Use a wildcard (*) to collect a counter for all instances. "
            "To get a list of performance counters on Windows, run the command 'typeperf'."
        )

    with self.argument_context(
            'monitor data-collection rule performance-counter list') as c:
        c.argument('data_collection_rule_name', id_part=None)

    with self.argument_context(
            'monitor data-collection rule windows-event-log') as c:
        c.argument('data_collection_rule_name', options_list=['--rule-name'])
        c.argument(
            'name',
            options_list=['--name', '-n'],
            help=
            'A friendly name for the data source. This name should be unique across all data sources '
            '(regardless of type) within the data collection rule.')
        c.argument(
            'streams',
            options_list=['--streams'],
            arg_type=get_enum_type(KnownWindowsEventLogDataSourceStreams),
            nargs='+',
            help=
            'List of streams that this data source will be sent to. A stream '
            'indicates what schema will be used for this data and usually what table in Log Analytics the data '
            'will be sent to.')
        c.argument(
            'scheduled_transfer_period',
            options_list=['--transfer-period'],
            arg_type=get_enum_type(
                KnownWindowsEventLogDataSourceScheduledTransferPeriod),
            help=
            'The interval between data uploads (scheduled transfers), rounded up to the nearest minute.'
        )
        c.argument('x_path_queries',
                   options_list=['--x-path-queries'],
                   nargs='+',
                   help='A list of Windows Event Log queries in XPATH format.')

    with self.argument_context(
            'monitor data-collection rule windows-event-log list') as c:
        c.argument('data_collection_rule_name', id_part=None)

    with self.argument_context('monitor data-collection rule syslog') as c:
        c.argument('data_collection_rule_name', options_list=['--rule-name'])
        c.argument(
            'name',
            options_list=['--name', '-n'],
            help=
            'A friendly name for the data source. This name should be unique across all data sources '
            '(regardless of type) within the data collection rule.')
        c.argument(
            'streams',
            options_list=['--streams'],
            arg_type=get_enum_type(KnownSyslogDataSourceStreams),
            nargs='+',
            help=
            'List of streams that this data source will be sent to. A stream '
            'indicates what schema will be used for this data and usually what table in Log Analytics the data '
            'will be sent to.')
        c.argument('facility_names',
                   options_list=['--facility-names'],
                   arg_type=get_enum_type(KnownSyslogDataSourceFacilityNames),
                   nargs='+',
                   help='The list of facility names.')
        c.argument('log_levels',
                   options_list=['--log-levels'],
                   arg_type=get_enum_type(KnownSyslogDataSourceLogLevels),
                   nargs='+',
                   help='The log levels to collect.')

    with self.argument_context(
            'monitor data-collection rule syslog list') as c:
        c.argument('data_collection_rule_name', id_part=None)
示例#49
0
def load_arguments(self, _):  # pylint: disable=too-many-statements
    # Arguments for IoT DPS
    with self.argument_context('iot dps') as c:
        c.argument('dps_name',
                   dps_name_type,
                   options_list=['--name', '-n'],
                   id_part='name')

    with self.argument_context('iot dps create') as c:
        c.argument(
            'location',
            get_location_type(self.cli_ctx),
            help=
            'Location of your IoT Provisioning Service. Default is the location of target resource group.'
        )
        c.argument('sku',
                   arg_type=get_enum_type(IotDpsSku),
                   help='Pricing tier for the IoT provisioning service.')
        c.argument('unit',
                   help='Units in your IoT Provisioning Service.',
                   type=int)

    for subgroup in ['access-policy', 'linked-hub', 'certificate']:
        with self.argument_context('iot dps {}'.format(subgroup)) as c:
            c.argument('dps_name', options_list=['--dps-name'], id_part=None)

    with self.argument_context('iot dps access-policy') as c:
        c.argument('access_policy_name',
                   options_list=['--access-policy-name', '--name', '-n'],
                   help='A friendly name for DPS access policy.')

    with self.argument_context('iot dps access-policy create') as c:
        c.argument(
            'rights',
            options_list=['--rights', '-r'],
            nargs='+',
            arg_type=get_enum_type(AccessRightsDescription),
            help=
            'Access rights for the IoT provisioning service. Use space-separated list for multiple rights.'
        )
        c.argument('primary_key', help='Primary SAS key value.')
        c.argument('secondary_key', help='Secondary SAS key value.')

    with self.argument_context('iot dps access-policy update') as c:
        c.argument(
            'rights',
            options_list=['--rights', '-r'],
            nargs='+',
            arg_type=get_enum_type(AccessRightsDescription),
            help=
            'Access rights for the IoT provisioning service. Use space-separated list for multiple rights.'
        )
        c.argument('primary_key', help='Primary SAS key value.')
        c.argument('secondary_key', help='Secondary SAS key value.')

    with self.argument_context('iot dps linked-hub') as c:
        c.argument('linked_hub',
                   options_list=['--linked-hub'],
                   help='Host name of linked IoT Hub.')

    with self.argument_context('iot dps linked-hub create') as c:
        c.argument('connection_string',
                   help='Connection string of the IoT hub.')
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   help='Location of the IoT hub.')
        c.argument(
            'apply_allocation_policy',
            help=
            'A boolean indicating whether to apply allocation policy to the IoT hub.',
            arg_type=get_three_state_flag())
        c.argument('allocation_weight',
                   help='Allocation weight of the IoT hub.')

    with self.argument_context('iot dps linked-hub update') as c:
        c.argument(
            'apply_allocation_policy',
            help=
            'A boolean indicating whether to apply allocation policy to the Iot hub.',
            arg_type=get_three_state_flag())
        c.argument('allocation_weight',
                   help='Allocation weight of the IoT hub.')

    with self.argument_context('iot dps allocation-policy update') as c:
        c.argument('allocation_policy',
                   options_list=['--policy', '-p'],
                   arg_type=get_enum_type(AllocationPolicy),
                   help='Allocation policy for the IoT provisioning service.')

    with self.argument_context('iot dps certificate') as c:
        c.argument('certificate_path',
                   options_list=['--path', '-p'],
                   type=file_type,
                   completer=FilesCompleter([".cer", ".pem"]),
                   help='The path to the file containing the certificate.')
        c.argument('certificate_name',
                   options_list=['--certificate-name', '--name', '-n'],
                   help='A friendly name for the certificate.')
        c.argument('etag',
                   options_list=['--etag', '-e'],
                   help='Entity Tag (etag) of the object.')

    # Arguments for IoT Hub
    with self.argument_context('iot hub') as c:
        c.argument('hub_name',
                   hub_name_type,
                   options_list=['--name', '-n'],
                   id_part='name')
        c.argument('etag',
                   options_list=['--etag', '-e'],
                   help='Entity Tag (etag) of the object.')
        c.argument(
            'sku',
            arg_type=get_enum_type(IotHubSku),
            help='Pricing tier for Azure IoT Hub. '
            'Note that only one free IoT hub instance (F1) is allowed in each '
            'subscription. Exception will be thrown if free instances exceed one.'
        )
        c.argument('unit', help='Units in your IoT Hub.', type=int)
        c.argument(
            'partition_count',
            help=
            'The number of partitions of the backing Event Hub for device-to-cloud messages.',
            type=int)
        c.argument(
            'retention_day',
            options_list=['--retention-day', '--rd'],
            type=int,
            validator=validate_retention_days,
            help=
            'Specifies how long this IoT hub will maintain device-to-cloud events, between 1 and 7 days.'
        )
        c.argument(
            'c2d_ttl',
            options_list=['--c2d-ttl', '--ct'],
            type=int,
            validator=validate_c2d_ttl,
            help=
            'The amount of time a message is available for the device to consume before it is expired'
            ' by IoT Hub, between 1 and 48 hours.')
        c.argument(
            'c2d_max_delivery_count',
            options_list=['--c2d-max-delivery-count', '--cdd'],
            type=int,
            validator=validate_c2d_max_delivery_count,
            help=
            'The number of times the IoT hub will attempt to deliver a cloud-to-device'
            ' message to a device, between 1 and 100.')
        c.argument(
            'feedback_ttl',
            options_list=['--feedback-ttl', '--ft'],
            type=int,
            validator=validate_feedback_ttl,
            help=
            'The period of time for which the IoT hub will maintain the feedback for expiration'
            ' or delivery of cloud-to-device messages, between 1 and 48 hours.'
        )
        c.argument(
            'feedback_lock_duration',
            options_list=['--feedback-lock-duration', '--fld'],
            type=int,
            validator=validate_feedback_lock_duration,
            help=
            'The lock duration for the feedback queue, between 5 and 300 seconds.'
        )
        c.argument(
            'feedback_max_delivery_count',
            options_list=['--feedback-max-delivery-count', '--fd'],
            type=int,
            validator=validate_feedback_max_delivery_count,
            help='The number of times the IoT hub attempts to'
            ' deliver a message on the feedback queue, between 1 and 100.')
        c.argument(
            'enable_fileupload_notifications',
            options_list=['--fileupload-notifications', '--fn'],
            arg_type=get_three_state_flag(),
            help=
            'A boolean indicating whether to log information about uploaded files to the'
            ' messages/servicebound/filenotifications IoT Hub endpoint.')
        c.argument(
            'fileupload_notification_max_delivery_count',
            type=int,
            options_list=[
                '--fileupload-notification-max-delivery-count', '--fnd'
            ],
            validator=validate_fileupload_notification_max_delivery_count,
            help=
            'The number of times the IoT hub will attempt to deliver a file notification message,'
            ' between 1 and 100.')
        c.argument(
            'fileupload_notification_ttl',
            options_list=['--fileupload-notification-ttl', '--fnt'],
            type=int,
            validator=validate_fileupload_notification_ttl,
            help=
            'The amount of time a file upload notification is available for the service to'
            ' consume before it is expired by IoT Hub, between 1 and 48 hours.'
        )
        c.argument(
            'fileupload_storage_connectionstring',
            options_list=['--fileupload-storage-connectionstring', '--fcs'],
            help=
            'The connection string for the Azure Storage account to which files are uploaded.'
        )
        c.argument(
            'fileupload_storage_authentication_type',
            options_list=['--fileupload-storage-auth-type', '--fsa'],
            help=
            'The authentication type for the Azure Storage account to which files are uploaded.'
            'Possible values are keyBased and identityBased')
        c.argument(
            'fileupload_storage_container_uri',
            options_list=['--fileupload-storage-container-uri', '--fcu'],
            help=
            'The container URI for the Azure Storage account to which files are uploaded.'
        )
        c.argument(
            'fileupload_storage_container_name',
            options_list=['--fileupload-storage-container-name', '--fc'],
            help=
            'The name of the root container where you upload files. The container need not exist but'
            ' should be creatable using the connectionString specified.')
        c.argument(
            'fileupload_sas_ttl',
            options_list=['--fileupload-sas-ttl', '--fst'],
            type=int,
            validator=validate_fileupload_sas_ttl,
            help=
            'The amount of time a SAS URI generated by IoT Hub is valid before it expires,'
            ' between 1 and 24 hours.')
        c.argument(
            'min_tls_version',
            options_list=['--min-tls-version', '--mintls'],
            type=str,
            help=
            'Specify the minimum TLS version to support for this hub. Can be set to'
            ' "1.2" to have clients that use a TLS version below 1.2 to be rejected.'
        )

    for subgroup in [
            'consumer-group', 'policy', 'certificate', 'routing-endpoint',
            'route'
    ]:
        with self.argument_context('iot hub {}'.format(subgroup)) as c:
            c.argument('hub_name', options_list=['--hub-name'])

    with self.argument_context('iot hub route') as c:
        c.argument('route_name',
                   options_list=['--route-name', '--name', '-n'],
                   help='Name of the Route.')
        c.argument('endpoint_name',
                   options_list=['--endpoint-name', '--endpoint', '--en'],
                   help='Name of the routing endpoint.')
        c.argument(
            'condition',
            options_list=['--condition', '-c'],
            help='Condition that is evaluated to apply the routing rule.')
        c.argument(
            'enabled',
            options_list=['--enabled', '-e'],
            arg_type=get_three_state_flag(),
            help='A boolean indicating whether to enable route to the Iot hub.'
        )
        c.argument('source_type',
                   arg_type=get_enum_type(RouteSourceType),
                   options_list=['--source-type', '--type', '--source', '-s'],
                   help='Source of the route.')

    with self.argument_context('iot hub route test') as c:
        c.argument('body',
                   options_list=['--body', '-b'],
                   help='Body of the route message.')
        c.argument('app_properties',
                   options_list=['--app-properties', '--ap'],
                   help='App properties of the route message.')
        c.argument('system_properties',
                   options_list=['--system-properties', '--sp'],
                   help='System properties of the route message.')

    with self.argument_context('iot hub routing-endpoint') as c:
        c.argument('endpoint_name',
                   options_list=['--endpoint-name', '--name', '-n'],
                   help='Name of the Routing Endpoint.')
        c.argument('endpoint_resource_group',
                   options_list=['--endpoint-resource-group', '--erg', '-r'],
                   help='Resource group of the Endpoint resoure.')
        c.argument('endpoint_subscription_id',
                   options_list=['--endpoint-subscription-id', '-s'],
                   help='SubscriptionId of the Endpoint resource.')
        c.argument('connection_string',
                   options_list=['--connection-string', '-c'],
                   help='Connection string of the Routing Endpoint.')
        c.argument('container_name',
                   options_list=['--container-name', '--container'],
                   help='Name of the storage container.')
        c.argument('endpoint_type',
                   arg_type=get_enum_type(EndpointType),
                   options_list=['--endpoint-type', '--type', '-t'],
                   help='Type of the Routing Endpoint.')
        c.argument(
            'encoding',
            options_list=['--encoding'],
            arg_type=get_enum_type(EncodingFormat),
            help='Encoding format for the container. The default is AVRO. '
            'Note that this field is applicable only for blob container endpoints.'
        )
        c.argument('endpoint_uri',
                   options_list=['--endpoint-uri'],
                   help='The uri of the endpoint resource.')
        c.argument('entity_path',
                   options_list=['--entity-path'],
                   help='The entity path of the endpoint resource.')

    with self.argument_context('iot hub routing-endpoint create') as c:
        c.argument(
            'batch_frequency',
            options_list=['--batch-frequency', '-b'],
            type=int,
            help=
            'Request batch frequency in seconds. The maximum amount of time that can elapse before data is'
            ' written to a blob, between 60 and 720 seconds.')
        c.argument(
            'chunk_size_window',
            options_list=['--chunk-size', '-w'],
            type=int,
            help=
            'Request chunk size in megabytes(MB). The maximum size of blobs, between 10 and 500 MB.'
        )
        c.argument(
            'file_name_format',
            options_list=['--file-name-format', '--ff'],
            help=
            'File name format for the blob. The file name format must contain {iothub},'
            ' {partition}, {YYYY}, {MM}, {DD}, {HH} and {mm} fields. All parameters are'
            ' mandatory but can be reordered with or without delimiters.')
        c.argument(
            'authentication_type',
            options_list=['--auth-type'],
            arg_type=get_enum_type(AuthenticationType),
            help=
            'Authentication type for the endpoint. The default is keyBased.')

    with self.argument_context('iot hub certificate') as c:
        c.argument('certificate_path',
                   options_list=['--path', '-p'],
                   type=file_type,
                   completer=FilesCompleter([".cer", ".pem"]),
                   help='The path to the file containing the certificate.')
        c.argument('certificate_name',
                   options_list=['--name', '-n'],
                   help='A friendly name for the certificate.')

    with self.argument_context('iot hub consumer-group') as c:
        c.argument('consumer_group_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='Event hub consumer group name.')
        c.argument('event_hub_name',
                   id_part='child_name_1',
                   help='Event hub endpoint name.')

    with self.argument_context('iot hub policy') as c:
        c.argument('policy_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='Shared access policy name.')
        permission_values = ', '.join([x.value for x in SimpleAccessRights])
        c.argument(
            'permissions',
            nargs='*',
            validator=validate_policy_permissions,
            type=str.lower,
            help=
            'Permissions of shared access policy. Use space-separated list for multiple permissions. '
            'Possible values: {}'.format(permission_values))

    with self.argument_context('iot hub policy renew-key') as c:
        c.argument('regenerate_key',
                   options_list=['--renew-key', '--rk'],
                   arg_type=get_enum_type(RenewKeyType),
                   help='Regenerate keys')

    with self.argument_context('iot hub create') as c:
        c.argument('hub_name', completer=None)
        c.argument(
            'location',
            get_location_type(self.cli_ctx),
            help=
            'Location of your IoT Hub. Default is the location of target resource group.'
        )

    with self.argument_context('iot hub show-connection-string') as c:
        c.argument('show_all',
                   options_list=['--all'],
                   help='Allow to show all shared access policies.')
        c.argument('hub_name', options_list=['--hub-name', '--name', '-n'])
        c.argument('policy_name', help='Shared access policy to use.')
        c.argument('key_type',
                   arg_type=get_enum_type(KeyType),
                   options_list=['--key'],
                   help='The key to use.')

    # Arguments for Message Enrichments
    with self.argument_context('iot hub message-enrichment') as c:
        c.argument('key',
                   options_list=['--key', '-k'],
                   help='The enrichment\'s key.')
        c.argument('value',
                   options_list=['--value', '-v'],
                   help='The enrichment\'s value.')
        c.argument(
            'endpoints',
            options_list=['--endpoints', '-e'],
            nargs='*',
            help=
            'Endpoint(s) to apply enrichments to. Use a space-separated list for multiple endpoints.'
        )

    with self.argument_context('iot central app') as c:
        c.argument('app_name', app_name_type, options_list=['--name', '-n'])

    with self.argument_context('iot central app create') as c:
        c.argument(
            'app_name',
            completer=None,
            help=
            'Give your IoT Central app a unique name so you can find it later.'
            'This will be used as the resource name in the Azure portal and CLI.'
            'Avoid special characters `-` '
            'instead, use lower case letters (a-z), numbers (0-9), and dashes (-)'
        )
        c.argument(
            'location',
            get_location_type(self.cli_ctx),
            help=
            'Where your app\'s info and resources are stored. We will default to the location'
            ' of the target resource group. See documentation for a full list of supported locations.'
        )
        c.argument('sku',
                   arg_type=get_enum_type(AppSku),
                   options_list=['--sku', '-p'],
                   help='Pricing plan for IoT Central application.')
        c.argument(
            'subdomain',
            options_list=['--subdomain', '-s'],
            help=
            'Enter a unique URL. Your app will be accessible via https://<subdomain>.azureiotcentral.com/.'
            ' Avoid special characters `-` instead, use lower '
            'case letters (a-z), numbers (0-9), and dashes (-).')
        c.argument(
            'template',
            options_list=['--template', '-t'],
            help=
            'IoT Central application template name. Default is "Custom application". See documentation for'
            ' a list of available templates.')
        c.argument(
            'display_name',
            options_list=['--display-name', '-d'],
            help=
            'Custom display name for the IoT Central app. This will be used in the IoT Central application'
            ' manager to help you identify your app. Default value is the resource name.'
        )
示例#50
0
def load_arguments(self, _):

    (IpsecEncryption, IpsecIntegrity, IkeEncryption, IkeIntegrity, DhGroup,
     PfsGroup, VirtualNetworkGatewayConnectionProtocol, AuthenticationMethod,
     HubRoutingPreference) = self.get_models(
         'IpsecEncryption', 'IpsecIntegrity', 'IkeEncryption', 'IkeIntegrity',
         'DhGroup', 'PfsGroup', 'VirtualNetworkGatewayConnectionProtocol',
         'AuthenticationMethod', 'HubRoutingPreference')

    (VpnGatewayTunnelingProtocol,
     VpnAuthenticationType) = self.get_models('VpnGatewayTunnelingProtocol',
                                              'VpnAuthenticationType')

    # region VirtualWAN
    vwan_name_type = CLIArgumentType(
        options_list='--vwan-name',
        metavar='NAME',
        help='Name of the virtual WAN.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/virtualWANs'))
    vhub_name_type = CLIArgumentType(
        options_list='--vhub-name',
        metavar='NAME',
        help='Name of the virtual hub.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/networkHubs'))
    vpn_gateway_name_type = CLIArgumentType(
        options_list='--gateway-name',
        metavar='NAME',
        help='Name of the VPN gateway.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/vpnGateways'))
    vpn_site_name_type = CLIArgumentType(
        options_list='--site-name',
        metavar='NAME',
        help='Name of the VPN site config.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/vpnSites'))
    p2s_vpn_gateway_name_type = CLIArgumentType(
        options_list='--gateway-name',
        metavar='NAME',
        help='Name of the P2S VPN gateway.',
        id_part='name',
        completer=get_resource_name_completion_list(
            'Microsoft.Network/p2svpnGateways'))
    associated_route_table_type = CLIArgumentType(
        options_list=['--associated', '--associated-route-table'],
        help=
        'The resource id of route table associated with this routing configuration.'
    )
    propagated_route_tables_type = CLIArgumentType(
        options_list=['--propagated', '--propagated-route-tables'],
        nargs='+',
        help='Space-separated list of resource id of propagated route tables.')
    propagated_route_tables_label_type = CLIArgumentType(
        nargs='+',
        help='Space-separated list of labels for propagated route tables.')

    with self.argument_context('network') as c:
        c.argument('tags', tags_type)

    with self.argument_context('network vwan') as c:
        c.argument('virtual_wan_name',
                   vwan_name_type,
                   options_list=['--name', '-n'])
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('branch_to_branch_traffic',
                   arg_type=get_three_state_flag(),
                   help='Allow branch-to-branch traffic flow.')
        c.argument('security_provider_name',
                   help='The security provider name.')
        c.argument('office365_category',
                   help='The office local breakout category.')
        c.argument('disable_vpn_encryption',
                   arg_type=get_three_state_flag(),
                   help='State of VPN encryption.')
        c.argument('vwan_type',
                   options_list='--type',
                   arg_type=get_enum_type(['Basic', 'Standard']),
                   help='The type of the VirtualWAN.')
    # endregion

    # region VirtualHub
    with self.argument_context('network vhub') as c:
        c.argument('virtual_hub_name',
                   vhub_name_type,
                   options_list=['--name', '-n'])
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('virtual_wan',
                   options_list='--vwan',
                   help='Name or ID of the virtual WAN.',
                   validator=get_network_resource_name_or_id(
                       'virtual_wan', 'virtualWans'))
        c.argument('address_prefix',
                   help='CIDR address prefix for the virtual hub.')
        c.argument('sku',
                   arg_type=get_enum_type(['Basic', 'Standard']),
                   help='The sku of the VirtualHub.')
        c.argument('hub_routing_preference',
                   arg_type=get_enum_type(HubRoutingPreference),
                   help='The hub routing preference gateway types')

    with self.argument_context('network vhub', arg_group='Gateway') as c:
        c.argument('express_route_gateway',
                   help='Name or ID of an ExpressRoute gateway.',
                   validator=get_network_resource_name_or_id(
                       'express_route_gateway', 'expressRouteGateways'))
        c.argument('p2s_vpn_gateway',
                   help='Name or ID of a P2S VPN gateway.',
                   validator=get_network_resource_name_or_id(
                       'p2s_vpn_gateway', 'P2sVpnGateways'))
        c.argument('vpn_gateway',
                   help='Name or ID of a VPN gateway.',
                   validator=get_network_resource_name_or_id(
                       'vpn_gateway', 'vpnGateways'))

    with self.argument_context('network vhub get-effective-routes') as c:
        c.argument(
            'virtual_wan_resource_type',
            options_list='--resource-type',
            help=
            'The type of the specified resource like RouteTable, ExpressRouteConnection, HubVirtualNetworkConnection, VpnConnection and P2SConnection.'
        )
        c.argument(
            'resource_id',
            options_list='--resource-id',
            help='The resource whose effective routes are being requested')

    with self.argument_context('network vhub connection') as c:
        c.argument('virtual_hub_name', vhub_name_type)
        c.argument('connection_name',
                   help='Name of the connection.',
                   options_list=['--name', '-n'],
                   id_part='child_name_1')
        c.argument('remote_virtual_network',
                   options_list='--remote-vnet',
                   help='Name of ID of the remote VNet to connect to.',
                   validator=get_network_resource_name_or_id(
                       'remote_virtual_network', 'virtualNetworks'))
        c.argument('allow_hub_to_remote_vnet_transit',
                   arg_type=get_three_state_flag(),
                   options_list='--remote-vnet-transit',
                   deprecate_info=c.deprecate(target='--remote-vnet-transit'),
                   help='Enable hub to remote VNet transit.')
        c.argument(
            'allow_remote_vnet_to_use_hub_vnet_gateways',
            arg_type=get_three_state_flag(),
            options_list='--use-hub-vnet-gateways',
            deprecate_info=c.deprecate(target='--use-hub-vnet-gateways'),
            help='Allow remote VNet to use hub\'s VNet gateways.')
        c.argument('enable_internet_security',
                   arg_type=get_three_state_flag(),
                   options_list='--internet-security',
                   help='Enable internet security and default is enabled.',
                   default=True)

    with self.argument_context('network vhub connection list') as c:
        c.argument('virtual_hub_name', vhub_name_type, id_part=None)

    with self.argument_context('network vhub connection',
                               arg_group='RoutingConfiguration',
                               min_api='2020-04-01',
                               is_preview=True) as c:
        c.argument('address_prefixes',
                   nargs='+',
                   help='Space-separated list of all address prefixes.')
        c.argument('next_hop_ip_address',
                   options_list='--next-hop',
                   help='The ip address of the next hop.')
        c.argument(
            'route_name',
            help=
            'The name of the Static Route that is unique within a Vnet Route.')

    with self.argument_context('network vhub bgpconnection') as c:
        c.argument('virtual_hub_name', vhub_name_type)
        c.argument('connection_name',
                   help='Name of the bgpconnection.',
                   options_list=['--name', '-n'],
                   id_part='child_name_1')
        c.argument('peer_asn', help='Peer ASN', type=int)
        c.argument('peer_ip', help='Peer IP')
        c.argument('virtual_hub_connection',
                   options_list='--vhub-conn',
                   help='The resource id of vhub connection.')

    with self.argument_context('network vhub bgpconnection list') as c:
        c.argument('virtual_hub_name', id_part=None)

    with self.argument_context('network vhub route') as c:
        c.argument('virtual_hub_name', vhub_name_type, id_part=None)
        c.argument('address_prefixes',
                   nargs='+',
                   help='Space-separated list of CIDR prefixes.')
        c.argument('next_hop_ip_address',
                   options_list='--next-hop',
                   help='IP address of the next hop.')
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')

    with self.argument_context('network vhub route-table') as c:
        c.argument('virtual_hub_name', vhub_name_type, id_part=None)
        c.argument('route_table_name',
                   options_list=['--name', '-n'],
                   help='Name of the virtual hub route table.')
        c.argument('attached_connections',
                   options_list='--connections',
                   nargs='+',
                   arg_type=get_enum_type(['All_Vnets', 'All_Branches']),
                   help='List of all connections attached to this route table',
                   arg_group="route table v2",
                   deprecate_info=c.deprecate(hide=False))
        c.argument('destination_type',
                   arg_type=get_enum_type(['Service', 'CIDR', 'ResourceId']),
                   help='The type of destinations')
        c.argument('destinations',
                   nargs='+',
                   help='Space-separated list of all destinations.')
        c.argument(
            'next_hop_type',
            arg_type=get_enum_type(['IPAddress', 'ResourceId']),
            help=
            'The type of next hop. If --next-hops (v2) is provided, it should be IPAddress; if --next-hop (v3) is provided, it should be ResourceId.'
        )
        c.argument(
            'next_hops',
            nargs='+',
            help=
            'Space-separated list of IP address of the next hop. Currently only one next hop is allowed for every route.',
            arg_group="route table v2",
            deprecate_info=c.deprecate(hide=False))
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')
        c.argument('next_hop',
                   help='The resource ID of the next hop.',
                   arg_group="route table v3",
                   min_api='2020-04-01')
        c.argument('route_name',
                   help='The name of the route.',
                   arg_group="route table v3",
                   min_api='2020-04-01')
        c.argument(
            'labels',
            nargs='+',
            help=
            'Space-separated list of all labels associated with this route table.',
            arg_group="route table v3",
            min_api='2020-04-01')
    # endregion

    # region VpnGateways
    with self.argument_context('network vpn-gateway') as c:
        c.argument('virtual_hub',
                   options_list='--vhub',
                   help='Name or ID of a virtual hub.',
                   validator=get_network_resource_name_or_id(
                       'virtual_hub', 'virtualHubs'))
        c.argument('scale_unit',
                   type=int,
                   help='The scale unit for this VPN gateway.')
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('gateway_name',
                   vpn_gateway_name_type,
                   options_list=['--name', '-n'])

    with self.argument_context('network vpn-gateway connection') as c:
        for dest in ['gateway_name', 'resource_name']:
            c.argument(dest, vpn_gateway_name_type)
        for dest in ['item_name', 'connection_name']:
            c.argument(dest,
                       help='Name of the VPN gateway connection.',
                       options_list=['--name', '-n'],
                       id_part='child_name_1')
        c.argument('remote_vpn_site',
                   help='Name of ID of the remote VPN site.',
                   validator=get_network_resource_name_or_id(
                       'remote_vpn_site', 'vpnSites'))
        c.argument('connection_bandwidth',
                   help='Expected bandwidth in Mbps.',
                   type=int)
        c.argument('enable_bgp',
                   arg_type=get_three_state_flag(),
                   help='Enable BGP.')
        c.argument('enable_internet_security',
                   options_list='--internet-security',
                   arg_type=get_three_state_flag(),
                   help='Enable internet security.')
        c.argument('enable_rate_limiting',
                   options_list='--rate-limiting',
                   arg_type=get_three_state_flag(),
                   help='Enable rate limiting.')
        c.argument(
            'protocol_type',
            arg_type=get_enum_type(VirtualNetworkGatewayConnectionProtocol),
            help='Connection protocol.')
        c.argument('routing_weight', type=int, help='Routing weight.')
        c.argument('shared_key', help='Shared key.')
        c.argument("vpn_site_link", help='The resource ID of VPN Site Link.')
        c.argument('with_link',
                   help='Create VpnConnection with default link.',
                   arg_type=get_three_state_flag())

    with self.argument_context('network vpn-gateway connection list') as c:
        # List commands cannot use --ids flag
        c.argument('resource_name', vpn_gateway_name_type, id_part=None)
        c.argument('gateway_name', id_part=None)

    with self.argument_context(
            'network vpn-gateway connection vpn-site-link-conn') as c:
        c.argument("connection_name",
                   help='Name of the VPN gateway connection.',
                   options_list=['--connection-name'])
        c.argument("item_name",
                   help='Name of the VPN gateway connection.',
                   options_list=['--connection-name'])
        c.argument("vpn_site_link_conn_name",
                   help='Name of the VPN site link connection.',
                   options_list=['--name', '-n'],
                   id_part='child_name_1')
        c.argument("vpn_site_link", help='The resource ID of VPN Site Link.')
        c.argument('routing_weight', type=int, help='Routing weight.')
        c.argument('shared_key', help='Shared key.')
        c.argument('enable_rate_limiting',
                   options_list='--rate-limiting',
                   arg_type=get_three_state_flag(),
                   help='Enable rate limiting.')
        c.argument('connection_bandwidth',
                   help='Expected bandwidth in Mbps.',
                   type=int)
        c.argument('enable_bgp',
                   arg_type=get_three_state_flag(),
                   help='Enable BGP.')
        c.argument('use_local_azure_ip_address',
                   arg_type=get_three_state_flag(),
                   help='Use local azure ip to initiate connection.')
        c.argument('use_policy_based_traffic_selectors',
                   arg_type=get_three_state_flag(),
                   help='Enable policy-based traffic selectors.')
        c.argument('vpn_connection_protocol_type',
                   help='Connection protocol used for this connection.',
                   arg_type=get_enum_type(['IKEv2', 'IKEv1']))
        c.argument('vpn_link_connection_mode',
                   help='Vpn link connection mode.',
                   arg_type=get_enum_type(
                       ['Default', 'ResponderOnly', 'InitiatorOnly']))
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')

    with self.argument_context(
            'network vpn-gateway connection vpn-site-link-conn list') as c:
        c.argument('resource_name', vpn_gateway_name_type, id_part=None)
        c.argument('gateway_name', id_part=None)

    with self.argument_context(
            'network vpn-gateway connection vpn-site-link-conn ipsec-policy list'
    ) as c:
        c.argument('resource_name', vpn_gateway_name_type, id_part=None)
        c.argument('gateway_name', id_part=None)

    with self.argument_context('network vpn-gateway connection',
                               arg_group='IP Security') as c:
        c.argument(
            'sa_life_time_seconds',
            options_list='--sa-lifetime',
            help=
            'IPSec Security Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for a site-to-site VPN tunnel.',
            type=int)
        c.argument(
            'sa_data_size_kilobytes',
            options_list='--sa-data-size',
            help=
            'IPSec Security Association (also called Quick Mode or Phase 2 SA) payload size in KB for a site-to-site VPN tunnel.',
            type=int)
        c.argument('ipsec_encryption',
                   arg_type=get_enum_type(IpsecEncryption),
                   help='IPSec encryption algorithm (IKE phase 1).')
        c.argument('ipsec_integrity',
                   arg_type=get_enum_type(IpsecIntegrity),
                   help='IPSec integrity algorithm (IKE phase 1).')
        c.argument('ike_encryption',
                   arg_type=get_enum_type(IkeEncryption),
                   help='IKE encryption algorithm (IKE phase 2).')
        c.argument('ike_integrity',
                   arg_type=get_enum_type(IkeIntegrity),
                   help='IKE integrity algorithm (IKE phase 2).')
        c.argument('dh_group',
                   arg_type=get_enum_type(DhGroup),
                   help='DH Groups used in IKE Phase 1 for initial SA.')
        c.argument('pfs_group',
                   arg_type=get_enum_type(PfsGroup),
                   help='The Pfs Groups used in IKE Phase 2 for new child SA.')

    with self.argument_context(
            'network vpn-gateway connection ipsec-policy') as c:
        c.argument('gateway_name', vpn_gateway_name_type, id_part=None)
        c.argument('connection_name',
                   options_list='--connection-name',
                   help='Name of the VPN gateway connection.')
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')
    # endregion

    # region VpnSites
    with self.argument_context('network vpn-site') as c:
        c.argument('vpn_site_name',
                   vpn_site_name_type,
                   options_list=['--name', '-n'])
        c.argument('virtual_wan',
                   help='Name or ID of the virtual WAN.',
                   validator=get_network_resource_name_or_id(
                       'virtual_wan', 'virtualWans'))
        c.argument('is_security_site',
                   arg_type=get_three_state_flag(),
                   options_list='--security-site',
                   help='Whether the VPN site is security-related.')
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('ip_address', help='IP address of the VPN site.')
        c.argument(
            'site_key',
            help='Key for the VPN site that can be used for connections.')
        c.argument('address_prefixes',
                   nargs='+',
                   help='Space-separated list of CIDR address prefixes.')
        c.argument('with_link',
                   help='Create VPN site with default link.',
                   arg_type=get_three_state_flag())

    with self.argument_context('network vpn-site',
                               arg_group='Device Property') as c:
        c.argument('device_model', help='Model of the device.')
        c.argument('device_vendor', help='Name of the device vendor.')
        c.argument('link_speed', help='Link speed in Mbps.', type=int)

    with self.argument_context('network vpn-site link') as c:
        c.argument('vpn_site_name', vpn_site_name_type)
        c.argument('vpn_site_link_name',
                   help='The name of vpn site link.',
                   options_list=['--name', '-n'])
        c.argument('fqdn', help='FQDN of vpn-site-link.')
        c.argument('link_provider_name', help='Name of the link provider.')
        c.argument('link_speed_in_mbps', help='Link speed.', type=int)
        c.argument('index',
                   type=int,
                   help='List index of the item (starting with 1).')

    with self.argument_context('network vpn-site link list') as c:
        c.argument('resource_name', vpn_gateway_name_type, id_part=None)
        c.argument('virtual_wan_name', vwan_name_type, id_part=None)
        c.argument('vpn_site_name',
                   vpn_site_name_type,
                   options_list=['--site-name'],
                   id_part=None)

    for scope in ['vpn-site', 'vpn-gateway']:
        with self.argument_context('network {}'.format(scope),
                                   arg_group='BGP Peering') as c:
            c.argument('asn', help='BGP speaker\'s ASN.', type=int)
            c.argument(
                'peer_weight',
                help='Weight added to routes learned from this BGP speaker.',
                type=int)
            c.argument(
                'bgp_peering_address',
                help='Peering address and BGP identifier of this BGP speaker.')

    with self.argument_context('network vpn-site download') as c:
        c.argument('virtual_wan_name', vwan_name_type, id_part=None)
        c.argument('vpn_sites',
                   help='Space-separated list of VPN site names or IDs.',
                   nargs='+',
                   validator=get_network_resource_name_or_id(
                       'vpn_sites', 'vpnSites'))
    # endregion

    # region VpnServerConfigurations
    with self.argument_context('network vpn-server-config') as c:
        c.argument('vpn_protocols',
                   nargs='+',
                   options_list=['--protocols'],
                   arg_type=get_enum_type(VpnGatewayTunnelingProtocol),
                   help='VPN protocols for the VpnServerConfiguration.')
        c.argument(
            'vpn_auth_types',
            nargs='+',
            options_list=['--auth-types'],
            arg_type=get_enum_type(VpnAuthenticationType),
            help=
            'List of VPN authentication types for the VpnServerConfiguration.')
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('vpn_server_configuration_name',
                   options_list=['--name', '-n'],
                   help='Name of the Vpn server configuration.')
    with self.argument_context('network vpn-server-config',
                               arg_group='AAD Auth') as c:
        c.argument('aad_tenant',
                   help='AAD Vpn authentication parameter AAD tenant.')
        c.argument('aad_audience',
                   help='AAD Vpn authentication parameter AAD audience.')
        c.argument('aad_issuer',
                   help='AAD Vpn authentication parameter AAD issuer.')
    with self.argument_context('network vpn-server-config',
                               arg_group='Certificate Auth') as c:
        c.argument('vpn_client_root_certs',
                   help='List of VPN client root certificate file paths.',
                   nargs='+')
        c.argument('vpn_client_revoked_certs',
                   help='List of VPN client revoked certificate file paths.',
                   nargs='+')
    with self.argument_context('network vpn-server-config',
                               arg_group='Radius Auth') as c:
        c.argument('radius_client_root_certs',
                   help='List of Radius client root certificate file paths.',
                   nargs='+')
        c.argument('radius_server_root_certs',
                   help='List of Radius server root certificate file paths.',
                   nargs='+')
        c.argument('radius_servers',
                   nargs='+',
                   action=RadiusServerAddAction,
                   help='Radius Server configuration.')

    with self.argument_context('network vpn-server-config',
                               arg_group='IP Security') as c:
        c.argument(
            'sa_life_time_seconds',
            options_list='--sa-lifetime',
            help=
            'IPSec Security Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for a site-to-site VPN tunnel.',
            type=int)
        c.argument(
            'sa_data_size_kilobytes',
            options_list='--sa-data-size',
            help=
            'IPSec Security Association (also called Quick Mode or Phase 2 SA) payload size in KB for a site-to-site VPN tunnel.',
            type=int)
        c.argument('ipsec_encryption',
                   arg_type=get_enum_type(IpsecEncryption),
                   help='IPSec encryption algorithm (IKE phase 1).')
        c.argument('ipsec_integrity',
                   arg_type=get_enum_type(IpsecIntegrity),
                   help='IPSec integrity algorithm (IKE phase 1).')
        c.argument('ike_encryption',
                   arg_type=get_enum_type(IkeEncryption),
                   help='IKE encryption algorithm (IKE phase 2).')
        c.argument('ike_integrity',
                   arg_type=get_enum_type(IkeIntegrity),
                   help='IKE integrity algorithm (IKE phase 2).')
        c.argument('dh_group',
                   arg_type=get_enum_type(DhGroup),
                   help='DH Groups used in IKE Phase 1 for initial SA.')
        c.argument('pfs_group',
                   arg_type=get_enum_type(PfsGroup),
                   help='The Pfs Groups used in IKE Phase 2 for new child SA.')
        c.argument('index',
                   type=int,
                   help='List index of the ipsec policy(starting with 0).')
    # endregion

    # region P2SVpnGateways
    with self.argument_context('network p2s-vpn-gateway') as c:
        c.argument(
            'address_space',
            nargs='+',
            help=
            'Address space for P2S VpnClient. Space-separated list of IP address ranges.'
        )
        c.argument('p2s_conn_config_name',
                   options_list=['--config-name'],
                   help='Name or p2s connection configuration.')
        c.argument('scale_unit',
                   type=int,
                   help='The scale unit for this VPN gateway.')
        c.argument('gateway_name',
                   options_list=['--name', '-n'],
                   help='Name of the P2S Vpn Gateway.')
        c.argument('virtual_hub',
                   options_list='--vhub',
                   help='Name or ID of a virtual hub.',
                   validator=get_network_resource_name_or_id(
                       'virtual_hub', 'virtualHubs'))
        c.argument('vpn_server_config',
                   help='Name or ID of a vpn server configuration.',
                   validator=get_network_resource_name_or_id(
                       'vpn_server_config', 'vpnServerConfigurations'))
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)

    with self.argument_context('network p2s-vpn-gateway connection') as c:
        for dest in ['gateway_name', 'resource_name']:
            c.argument(dest, p2s_vpn_gateway_name_type)
        c.argument('item_name',
                   help='Name of the P2S VPN gateway connection.',
                   options_list=['--name', '-n'],
                   id_part='child_name_1')

    with self.argument_context('network p2s-vpn-gateway connection list') as c:
        c.argument('resource_name', p2s_vpn_gateway_name_type, id_part=None)

    with self.argument_context('network p2s-vpn-gateway vpn-client') as c:
        c.argument('authentication_method',
                   arg_type=get_enum_type(AuthenticationMethod),
                   help='VPN client authentication method.')
    # endregion

    # region Routing Configuration
    for item in [
            'vpn-gateway connection', 'p2s-vpn-gateway', 'vhub connection'
    ]:
        with self.argument_context('network {}'.format(item),
                                   arg_group='Routing Configuration',
                                   min_api='2020-04-01',
                                   is_preview=True) as c:
            c.argument('associated_route_table', associated_route_table_type)
            c.argument('propagated_route_tables', propagated_route_tables_type)
            c.argument('labels', propagated_route_tables_label_type)
示例#51
0
def load_arguments(self, _):

    with self.argument_context('stream-analytics job list') as c:
        c.argument('expand', type=str, help='The $expand OData query parameter. This is a comma-separated list of '
                   'additional streaming job properties to include in the response, beyond the default set returned '
                   'when this parameter is absent. The default set is all streaming job properties other than '
                   '\'inputs\', \'transformation\', \'outputs\', and \'functions\'.')
        c.argument('resource_group_name', resource_group_name_type)

    with self.argument_context('stream-analytics job show') as c:
        c.argument('expand', type=str, help='The $expand OData query parameter. This is a comma-separated list of '
                   'additional streaming job properties to include in the response, beyond the default set returned '
                   'when this parameter is absent. The default set is all streaming job properties other than '
                   '\'inputs\', \'transformation\', \'outputs\', and \'functions\'.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics job create') as c:
        c.argument('if_match', type=str, help='The ETag of the streaming job. Omit this value to always overwrite the '
                   'current record set. Specify the last-seen ETag value to prevent accidentally overwriting '
                   'concurrent changes.')
        c.argument('if_none_match', type=str, help='Set to \'*\' to allow a new streaming job to be created, but to '
                   'prevent updating an existing record set. Other values will result in a 412 Pre-condition Failed '
                   'response.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')
        c.argument('tags', tags_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('identity', action=AddIdentity, nargs='+', help='Describes the system-assigned managed identity '
                   'assigned to this job that can be used to authenticate with inputs and outputs.')
        c.argument('job_type', arg_type=get_enum_type(['Cloud', 'Edge']), help='Describes the type of the job. Valid '
                   'modes are `Cloud` and \'Edge\'.')
        c.argument('output_start_mode', arg_type=get_enum_type(['JobStartTime', 'CustomTime', 'LastOutputEventTime']),
                   help='This property should only be utilized when it is desired that the job be started immediately '
                   'upon creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to indicate whether '
                   'the starting point of the output event stream should start whenever the job is started, start at a '
                   'custom user time stamp specified via the outputStartTime property, or start from the last event '
                   'output time.')
        c.argument('output_start_time', help='Value is either an ISO-8601 formatted time stamp that indicates the '
                   'starting point of the output event stream, or null to indicate that the output event stream will '
                   'start whenever the streaming job is started. This property must have a value if outputStartMode is '
                   'set to CustomTime.')
        c.argument('out_of_order_policy', arg_type=get_enum_type(['Adjust', 'Drop']), help='Indicates the policy to '
                   'apply to events that arrive out of order in the input event stream.')
        c.argument('output_error_policy', arg_type=get_enum_type(['Stop', 'Drop']), help='Indicates the policy to '
                   'apply to events that arrive at the output and cannot be written to the external storage due to '
                   'being malformed (missing column values, column values of wrong type or size).')
        c.argument('order_max_delay', type=int, help='The maximum tolerable delay in seconds where out-of-order events '
                   'can be adjusted to be back in order.')
        c.argument('arrival_max_delay', type=int, help='The maximum tolerable delay in seconds where events arriving '
                   'late could be included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is used to '
                   'specify wait indefinitely. If the property is absent, it is interpreted to have a value of -1.')
        c.argument('data_locale', type=str, help='The data locale of the stream analytics job. Value should be the '
                   'name of a supported .NET Culture from the set https://msdn.microsoft.com/en-us/library/system.globa'
                   'lization.culturetypes(v=vs.110).aspx. Defaults to \'en-US\' if none specified.')
        c.argument('compatibility_level', arg_type=get_enum_type(['1.0', '1.2']), help='Controls certain runtime '
                   'behaviors of the streaming job.')
        c.argument('inputs', type=validate_file_or_dict, help='A list of one or more inputs to the streaming job. The '
                   'name property for each input is required when specifying this property in a PUT request. This '
                   'property cannot be modify via a PATCH operation. You must use the PATCH API available for the '
                   'individual input. Expected value: json-string/json-file/@json-file.')
        c.argument('transformation', action=AddTransformation, nargs='+', help='Indicates the query and the number of '
                   'streaming units to use for the streaming job. The name property of the transformation is required '
                   'when specifying this property in a PUT request. This property cannot be modify via a PATCH '
                   'operation. You must use the PATCH API available for the individual transformation.')
        c.argument('outputs', type=validate_file_or_dict, help='A list of one or more outputs for the streaming job. '
                   'The name property for each output is required when specifying this property in a PUT request. This '
                   'property cannot be modify via a PATCH operation. You must use the PATCH API available for the '
                   'individual output. Expected value: json-string/json-file/@json-file.')
        c.argument('functions', type=validate_file_or_dict, help='A list of one or more functions for the streaming '
                   'job. The name property for each function is required when specifying this property in a PUT '
                   'request. This property cannot be modify via a PATCH operation. You must use the PATCH API '
                   'available for the individual transformation. Expected value: json-string/json-file/@json-file.')
        c.argument('job_storage_account', action=AddJobStorageAccount, nargs='+', help='The properties that are '
                   'associated with an Azure Storage account with MSI')
        c.argument('content_storage_policy', arg_type=get_enum_type(['SystemAccount', 'JobStorageAccount']),
                   help='Valid values are JobStorageAccount and SystemAccount. If set to JobStorageAccount, this '
                   'requires the user to also specify jobStorageAccount property. .')
        c.argument('id_', options_list=['--id'], type=str, help='The resource id of cluster.', arg_group='Cluster')

    with self.argument_context('stream-analytics job update') as c:
        c.argument('if_match', type=str, help='The ETag of the streaming job. Omit this value to always overwrite the '
                   'current record set. Specify the last-seen ETag value to prevent accidentally overwriting '
                   'concurrent changes.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')
        c.argument('tags', tags_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('identity', action=AddIdentity, nargs='+', help='Describes the system-assigned managed identity '
                   'assigned to this job that can be used to authenticate with inputs and outputs.')
        c.argument('job_type', arg_type=get_enum_type(['Cloud', 'Edge']), help='Describes the type of the job. Valid '
                   'modes are `Cloud` and \'Edge\'.')
        c.argument('output_start_mode', arg_type=get_enum_type(['JobStartTime', 'CustomTime', 'LastOutputEventTime']),
                   help='This property should only be utilized when it is desired that the job be started immediately '
                   'upon creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to indicate whether '
                   'the starting point of the output event stream should start whenever the job is started, start at a '
                   'custom user time stamp specified via the outputStartTime property, or start from the last event '
                   'output time.')
        c.argument('output_start_time', help='Value is either an ISO-8601 formatted time stamp that indicates the '
                   'starting point of the output event stream, or null to indicate that the output event stream will '
                   'start whenever the streaming job is started. This property must have a value if outputStartMode is '
                   'set to CustomTime.')
        c.argument('out_of_order_policy', arg_type=get_enum_type(['Adjust', 'Drop']), help='Indicates the policy to '
                   'apply to events that arrive out of order in the input event stream.')
        c.argument('output_error_policy', arg_type=get_enum_type(['Stop', 'Drop']), help='Indicates the policy to '
                   'apply to events that arrive at the output and cannot be written to the external storage due to '
                   'being malformed (missing column values, column values of wrong type or size).')
        c.argument('order_max_delay', type=int, help='The maximum tolerable delay in seconds where out-of-order events '
                   'can be adjusted to be back in order.')
        c.argument('arrival_max_delay', type=int, help='The maximum tolerable delay in seconds where events arriving '
                   'late could be included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is used to '
                   'specify wait indefinitely. If the property is absent, it is interpreted to have a value of -1.')
        c.argument('data_locale', type=str, help='The data locale of the stream analytics job. Value should be the '
                   'name of a supported .NET Culture from the set https://msdn.microsoft.com/en-us/library/system.globa'
                   'lization.culturetypes(v=vs.110).aspx. Defaults to \'en-US\' if none specified.')
        c.argument('compatibility_level', arg_type=get_enum_type(['1.0', '1.2']), help='Controls certain runtime '
                   'behaviors of the streaming job.')
        c.argument('inputs', type=validate_file_or_dict, help='A list of one or more inputs to the streaming job. The '
                   'name property for each input is required when specifying this property in a PUT request. This '
                   'property cannot be modify via a PATCH operation. You must use the PATCH API available for the '
                   'individual input. Expected value: json-string/json-file/@json-file.')
        c.argument('transformation', action=AddTransformation, nargs='+', help='Indicates the query and the number of '
                   'streaming units to use for the streaming job. The name property of the transformation is required '
                   'when specifying this property in a PUT request. This property cannot be modify via a PATCH '
                   'operation. You must use the PATCH API available for the individual transformation.')
        c.argument('outputs', type=validate_file_or_dict, help='A list of one or more outputs for the streaming job. '
                   'The name property for each output is required when specifying this property in a PUT request. This '
                   'property cannot be modify via a PATCH operation. You must use the PATCH API available for the '
                   'individual output. Expected value: json-string/json-file/@json-file.')
        c.argument('functions', type=validate_file_or_dict, help='A list of one or more functions for the streaming '
                   'job. The name property for each function is required when specifying this property in a PUT '
                   'request. This property cannot be modify via a PATCH operation. You must use the PATCH API '
                   'available for the individual transformation. Expected value: json-string/json-file/@json-file.')
        c.argument('job_storage_account', action=AddJobStorageAccount, nargs='+', help='The properties that are '
                   'associated with an Azure Storage account with MSI')
        c.argument('content_storage_policy', arg_type=get_enum_type(['SystemAccount', 'JobStorageAccount']),
                   help='Valid values are JobStorageAccount and SystemAccount. If set to JobStorageAccount, this '
                   'requires the user to also specify jobStorageAccount property. .')
        c.argument('id_', options_list=['--id'], type=str, help='The resource id of cluster.', arg_group='Cluster')

    with self.argument_context('stream-analytics job delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics job scale') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')
        c.argument('streaming_units', type=int, help='Specifies the number of streaming units that the streaming job '
                   'will scale to.')

    with self.argument_context('stream-analytics job start') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')
        c.argument('output_start_mode', arg_type=get_enum_type(['JobStartTime', 'CustomTime', 'LastOutputEventTime']),
                   help='Value may be JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the '
                   'starting point of the output event stream should start whenever the job is started, start at a '
                   'custom user time stamp specified via the outputStartTime property, or start from the last event '
                   'output time.')
        c.argument('output_start_time', help='Value is either an ISO-8601 formatted time stamp that indicates the '
                   'starting point of the output event stream, or null to indicate that the output event stream will '
                   'start whenever the streaming job is started. This property must have a value if outputStartMode is '
                   'set to CustomTime.')

    with self.argument_context('stream-analytics job stop') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics job wait') as c:
        c.argument('expand', type=str, help='The $expand OData query parameter. This is a comma-separated list of '
                   'additional streaming job properties to include in the response, beyond the default set returned '
                   'when this parameter is absent. The default set is all streaming job properties other than '
                   '\'inputs\', \'transformation\', \'outputs\', and \'functions\'.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', options_list=['--name', '-n', '--job-name'], type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics input list') as c:
        c.argument('select', type=str, help='The $select OData query parameter. This is a comma-separated list of '
                   'structural properties to include in the response, or "*" to include all properties. By default, '
                   'all properties are returned except diagnostics. Currently only accepts \'*\' as a valid value.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics input show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('input_name', options_list=['--name', '-n', '--input-name'], type=str, help='The name of the input.')

    with self.argument_context('stream-analytics input create') as c:
        c.argument('if_match', type=str, help='The ETag of the input. Omit this value to always overwrite the current '
                   'input. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes.')
        c.argument('if_none_match', type=str, help='Set to \'*\' to allow a new input to be created, but to prevent '
                   'updating an existing input. Other values will result in a 412 Pre-condition Failed response.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('input_name', options_list=['--name', '-n', '--input-name'], type=str, help='The name of the input.')
        c.argument('properties', type=validate_file_or_dict, help='The properties that are associated with an input. '
                   'Required on PUT (CreateOrReplace) requests. Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics input update') as c:
        c.argument('if_match', type=str, help='The ETag of the input. Omit this value to always overwrite the current '
                   'input. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('input_name', options_list=['--name', '-n', '--input-name'], type=str, help='The name of the input.')
        c.argument('properties', type=validate_file_or_dict, help='The properties that are associated with an input. '
                   'Required on PUT (CreateOrReplace) requests. Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics input delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('input_name', options_list=['--name', '-n', '--input-name'], type=str, help='The name of the input.')

    with self.argument_context('stream-analytics input test') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('input_name', options_list=['--name', '-n', '--input-name'], type=str, help='The name of the input.')
        c.argument('properties', type=validate_file_or_dict, help='The properties that are associated with an input. '
                   'Required on PUT (CreateOrReplace) requests. Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics input wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('input_name', options_list=['--name', '-n', '--input-name'], type=str, help='The name of the input.')

    with self.argument_context('stream-analytics output list') as c:
        c.argument('select', type=str, help='The $select OData query parameter. This is a comma-separated list of '
                   'structural properties to include in the response, or "*" to include all properties. By default, '
                   'all properties are returned except diagnostics. Currently only accepts \'*\' as a valid value.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics output show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('output_name', options_list=['--name', '-n', '--output-name'], type=str, help='The name of the output.')

    with self.argument_context('stream-analytics output create') as c:
        c.argument('if_match', type=str, help='The ETag of the output. Omit this value to always overwrite the current '
                   'output. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes.')
        c.argument('if_none_match', type=str, help='Set to \'*\' to allow a new output to be created, but to prevent '
                   'updating an existing output. Other values will result in a 412 Pre-condition Failed response.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('output_name', options_list=['--name', '-n', '--output-name'], type=str, help='The name of the output.')
        c.argument('datasource', type=validate_file_or_dict, help='Describes the data source that output will be '
                   'written to. Required on PUT (CreateOrReplace) requests. Expected value: '
                   'json-string/json-file/@json-file.')
        c.argument('time_window', type=str, help='The time frame for filtering Stream Analytics job outputs.')
        c.argument('size_window', type=float, help='The size window to constrain a Stream Analytics output to.')
        c.argument('serialization', type=validate_file_or_dict, help='Describes how data from an input is serialized '
                   'or how data is serialized when written to an output. Required on PUT (CreateOrReplace) requests. '
                   'Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics output update') as c:
        c.argument('if_match', type=str, help='The ETag of the output. Omit this value to always overwrite the current '
                   'output. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('output_name', options_list=['--name', '-n', '--output-name'], type=str, help='The name of the output.')
        c.argument('datasource', type=validate_file_or_dict, help='Describes the data source that output will be '
                   'written to. Required on PUT (CreateOrReplace) requests. Expected value: '
                   'json-string/json-file/@json-file.')
        c.argument('time_window', type=str, help='The time frame for filtering Stream Analytics job outputs.')
        c.argument('size_window', type=float, help='The size window to constrain a Stream Analytics output to.')
        c.argument('serialization', type=validate_file_or_dict, help='Describes how data from an input is serialized '
                   'or how data is serialized when written to an output. Required on PUT (CreateOrReplace) requests. '
                   'Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics output delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('output_name', options_list=['--name', '-n', '--output-name'], type=str, help='The name of the '
                   'output.')

    with self.argument_context('stream-analytics output test') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('output_name', options_list=['--name', '-n', '--output-name'], type=str, help='The name of the output.')
        c.argument('datasource', type=validate_file_or_dict, help='Describes the data source that output will be '
                   'written to. Required on PUT (CreateOrReplace) requests. Expected value: '
                   'json-string/json-file/@json-file.')
        c.argument('time_window', type=str, help='The time frame for filtering Stream Analytics job outputs.')
        c.argument('size_window', type=float, help='The size window to constrain a Stream Analytics output to.')
        c.argument('serialization', type=validate_file_or_dict, help='Describes how data from an input is serialized '
                   'or how data is serialized when written to an output. Required on PUT (CreateOrReplace) requests. '
                   'Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics output wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('output_name', options_list=['--name', '-n', '--output-name'], type=str, help='The name of the output.')

    with self.argument_context('stream-analytics transformation show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('transformation_name', options_list=['--name', '-n', '--transformation-name'], type=str, help='The '
                   'name of the transformation.')

    with self.argument_context('stream-analytics transformation create') as c:
        c.argument('if_match', type=str, help='The ETag of the transformation. Omit this value to always overwrite the '
                   'current transformation. Specify the last-seen ETag value to prevent accidentally overwriting '
                   'concurrent changes.')
        c.argument('if_none_match', type=str, help='Set to \'*\' to allow a new transformation to be created, but to '
                   'prevent updating an existing transformation. Other values will result in a 412 Pre-condition '
                   'Failed response.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('transformation_name', options_list=['--name', '-n', '--transformation-name'], type=str, help='The name of '
                   'the transformation.')
        c.argument('streaming_units', type=int, help='Specifies the number of streaming units that the streaming job '
                   'uses.')
        c.argument('valid_streaming_units', nargs='+', help='Specifies the valid streaming units a streaming job can '
                   'scale to.')
        c.argument('saql', type=str, help='Specifies the query that will be run in the streaming job. You can learn '
                   'more about the Stream Analytics Query Language (SAQL) here: https://msdn.microsoft.com/library/azur'
                   'e/dn834998 . Required on PUT (CreateOrReplace) requests.')

    with self.argument_context('stream-analytics transformation update') as c:
        c.argument('if_match', type=str, help='The ETag of the transformation. Omit this value to always overwrite the '
                   'current transformation. Specify the last-seen ETag value to prevent accidentally overwriting '
                   'concurrent changes.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('transformation_name', options_list=['--name', '-n', '--transformation-name'], type=str, help='The name of '
                   'the transformation.')
        c.argument('streaming_units', type=int, help='Specifies the number of streaming units that the streaming job '
                   'uses.')
        c.argument('valid_streaming_units', nargs='+', help='Specifies the valid streaming units a streaming job can '
                   'scale to.')
        c.argument('saql', type=str, help='Specifies the query that will be run in the streaming job. You can learn '
                   'more about the Stream Analytics Query Language (SAQL) here: https://msdn.microsoft.com/library/azur'
                   'e/dn834998 . Required on PUT (CreateOrReplace) requests.')

    with self.argument_context('stream-analytics function list') as c:
        c.argument('select', type=str, help='The $select OData query parameter. This is a comma-separated list of '
                   'structural properties to include in the response, or "*" to include all properties. By default, '
                   'all properties are returned except diagnostics. Currently only accepts \'*\' as a valid value.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')

    with self.argument_context('stream-analytics function show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('function_name', options_list=['--name', '-n', '--function-name'], type=str, help='The name of the '
                   'function.')

    with self.argument_context('stream-analytics function create') as c:
        c.argument('if_match', type=str, help='The ETag of the function. Omit this value to always overwrite the '
                   'current function. Specify the last-seen ETag value to prevent accidentally overwriting concurrent '
                   'changes.')
        c.argument('if_none_match', type=str, help='Set to \'*\' to allow a new function to be created, but to prevent '
                   'updating an existing function. Other values will result in a 412 Pre-condition Failed response.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('function_name', options_list=['--name', '-n', '--function-name'], type=str,
                   help='The name of the function.')
        c.argument('properties', type=validate_file_or_dict, help='The properties that are associated with a function. '
                   'Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics function update') as c:
        c.argument('if_match', type=str, help='The ETag of the function. Omit this value to always overwrite the '
                   'current function. Specify the last-seen ETag value to prevent accidentally overwriting concurrent '
                   'changes.')
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('function_name', options_list=['--name', '-n', '--function-name'], type=str,
                   help='The name of the function.')
        c.argument('properties', type=validate_file_or_dict, help='The properties that are associated with a function. '
                   'Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics function delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('function_name', options_list=['--name', '-n', '--function-name'], type=str, help='The name of the '
                   'function.')

    with self.argument_context('stream-analytics function test') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('function_name', options_list=['--name', '-n', '--function-name'], type=str,
                   help='The name of the function.')
        c.argument('properties', type=validate_file_or_dict, help='The properties that are associated with a function. '
                   'Expected value: json-string/json-file/@json-file.')

    with self.argument_context('stream-analytics function wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('job_name', type=str, help='The name of the streaming job.')
        c.argument('function_name', options_list=['--name', '-n', '--function-name'], type=str, help='The name of the '
                   'function.')

    with self.argument_context('stream-analytics subscription inspect') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name')
示例#52
0
def load_arguments(self, _):

    with self.argument_context('batchai') as c:
        c.argument('resource_group', resource_group_name_type)

    with self.argument_context('batchai cluster') as c:
        c.argument('location', get_location_type(self.cli_ctx), help='Location in which to create the cluster. If the location is not specified and default location is not configured, will default to the resource group\'s location')
        c.argument('cluster_name', options_list=['--name', '-n'], help='Name of the cluster.')

    with self.argument_context('batchai cluster create') as c:
        c.argument('json_file', options_list=['--config', '-c'], help='A path to a json file containing cluster create parameters (json representation of azure.mgmt.batchai.models.ClusterCreateParameters).', arg_group='Advanced')

    with self.argument_context('batchai cluster create') as c:
        c.argument('setup_task', help='A command line which should be executed on each compute node when it\'s got allocated or rebooted. The task is executed under a user account added into sudoers list (so, it can use sudo). Note, if this parameter is specified, it will overwrite setup task given in the configuration file.', arg_group='Setup Task')
        c.argument('setup_task_output', help='Location of the folder where setup-task\'s logs will be stored. Required if setup-task argument is provided. Note, Batch AI will create create several helper folders under this location. The created folders are reported as stdOutErrPathSuffix by get cluster command.', arg_group='Setup Task')

    with self.argument_context('batchai cluster create', arg_group='Virtual Network') as c:
        c.argument('subnet', options_list=['--subnet'], help='Resource id of a virtual network subnet to put the cluster in.')

    with self.argument_context('batchai cluster create', arg_group='Admin Account') as c:
        c.argument('user_name', options_list=['--user-name', '-u'], help='Name of the admin user account to be created on each compute node. If the value is not provided and no user configuration is provided in the config file, current user\'s name will be used.')
        c.argument('ssh_key', options_list=['--ssh-key', '-k'], help='SSH public key value or path. If the value is not provided and no ssh public key or password is configured in the config file the default public ssh key (~/.ssh/id_rsa.pub) of the current user will be used (if available).', completer=FilesCompleter())
        c.argument('generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing. The keys will be stored in the ~/.ssh directory.')
        c.argument('password', options_list=['--password', '-p'], help='Password.')

    with self.argument_context('batchai cluster create', arg_group='Auto Storage') as c:
        c.argument('use_auto_storage', action='store_true', help='If provided, the command will create a storage account in a new or existing resource group named "batchaiautostorage". It will also create Azure File Share with name "batchaishare", Azure Blob Container with name "batchaicontainer". The File Share and Blob Container will be mounted on each cluster node at $AZ_BATCHAI_MOUNT_ROOT/autoafs and $AZ_BATCHAI_MOUNT_ROOT/autobfs. If the resource group already exists and contains an approapriate storage account belonging to the same region as cluster, this command will reuse existing storage account.')

    with self.argument_context('batchai cluster create', arg_group='Nodes') as c:
        c.argument('image', options_list=['--image', '-i'], help='Operation system image for cluster nodes. The value may contain an alias ({0}) or specify image details in the form "publisher:offer:sku:version". If image configuration is not provided via command line or configuration file, Batch AI will choose default OS image'.format(', '.join(custom.SUPPORTED_IMAGE_ALIASES.keys())))
        c.argument('custom_image', help='Resource id of a virtual machine image to be used for nodes creation. Note, you need to provide --image with which this image was created.')
        c.argument('vm_size', options_list=['--vm-size', '-s'], help='VM size for cluster nodes (e.g. Standard_NC6 for 1 GPU node)', completer=get_vm_size_completion_list)
        c.argument('target', options_list=['--target', '-t'], help='Number of nodes which should be allocated immediately after cluster creation. If the cluster is in auto-scale mode, BatchAI can change the number of nodes later based on number of running and queued jobs.')
        c.argument('min_nodes', options_list=['--min'], help='Min nodes count for the auto-scale cluster.', type=int)
        c.argument('max_nodes', options_list=['--max'], help='Max nodes count for the auto-scale cluster.', type=int)
        c.argument('vm_priority', arg_type=get_enum_type(['dedicated', 'lowpriority']), options_list=['--vm-priority'], help="VM priority. If lowpriority selected the node can get preempted while the job is running.")

    with self.argument_context('batchai cluster create', arg_group='File Server Mount') as c:
        c.argument('nfs_name', options_list=['--nfs-name', '--nfs'], help='Name of a file server to mount on each cluster node. If you need to mount more than one file server, configure them in a configuration file and use --config option.')
        c.argument('nfs_resource_group', options_list=['--nfs-resource-group'], help='Resource group in which file server is created. Can be omitted if the file server and the cluster belong to the same resource group')
        c.argument('nfs_mount_path', options_list=['--nfs-mount-path'], help='Relative mount path for NFS. The NFS will be available at $AZ_BATCHAI_MOUNT_ROOT/<relative_mount_path> folder.')

    with self.argument_context('batchai cluster create', arg_group='Storage Account') as c:
        c.argument('account_name', options_list=['--storage-account-name'], help='Storage account name for Azure File Shares and/or Azure Storage Containers to be mounted on each cluster node. Related environment variable: AZURE_BATCHAI_STORAGE_ACCOUNT. Must be used in conjunction with --storage-account-key. If the key is not provided, the command will try to query the storage account key using the authenticated Azure account.')
        c.argument('account_key', options_list=['--storage-account-key'], help='Storage account key. Must be used in conjunction with --storage-account-name. Environment variable: AZURE_BATCHAI_STORAGE_KEY. Optional if the storage account belongs to the current subscription.')

    with self.argument_context('batchai cluster create', arg_group='Azure File Share Mount') as c:
        c.argument('azure_file_share', options_list=['--afs-name'], help='Name of the Azure File Share to be mounted on each cluster node. Must be used in conjunction with --storage-account-name and --storage-account-key arguments or AZURE_BATCHAI_STORAGE_ACCOUNT and AZURE_BATCHAI_STORAGE_KEY environment variables. If you need to mount more than one Azure File Share, configure them in a configuration file and use --config option.')
        c.argument('afs_mount_path', options_list=['--afs-mount-path'], help='Relative mount path for Azure File share. The file share will be available at $AZ_BATCHAI_MOUNT_ROOT/<relative_mount_path> folder.')

    with self.argument_context('batchai cluster create', arg_group='Azure Storage Container Mount') as c:
        c.argument('container_name', options_list=['--bfs-name', '--container-name'], help='Name of Azure Storage container to be mounted on each cluster node. Must be used in conjunction with --storage-account-name and --storage-account-key arguments or AZURE_BATCHAI_STORAGE_ACCOUNT and AZURE_BATCHAI_STORAGE_KEY environment variables. If you need to mount more than one Azure Storage Blob Container, configure them in a configuration file and use --config option.')
        c.argument('container_mount_path', options_list=['--bfs-mount-path', '--container-mount-path'], help='Relative mount path for Azure Storage container. The container will be available at $AZ_BATCHAI_MOUNT_ROOT/<relative_mount_path> folder.')

    with self.argument_context('batchai cluster resize') as c:
        c.argument('target', options_list=['--target', '-t'], help='Target number of compute nodes.')

    with self.argument_context('batchai cluster auto-scale') as c:
        c.argument('min_nodes', options_list=['--min'], help='Minimum number of nodes.')
        c.argument('max_nodes', options_list=['--max'], help='Maximum number of nodes.')

    with self.argument_context('batchai cluster list-files') as c:
        c.argument('path', options_list=['--path', '-p'], help='Relative path of a subfolder inside of node setup task output directory.')
        c.argument('expiry', options_list=['--expiry', '-e'], help='Time in minutes for how long generated download URLs should remain valid.')

    with self.argument_context('batchai cluster list') as c:
        # Not implemented yet
        c.ignore('clusters_list_options')

    with self.argument_context('batchai job') as c:
        c.argument('location', get_location_type(self.cli_ctx), help='Location in which to create the job. If default location is not configured, will default to the resource group\'s location')
        c.argument('job_name', options_list=['--name', '-n'], help='Name of the job.')
        c.argument('cluster_name', options_list=['--cluster-name', '-r'], help='Name of the cluster.')

    with self.argument_context('batchai job create') as c:
        c.argument('json_file', options_list=['--config', '-c'], help='A path to a json file containing job create parameters (json representation of azure.mgmt.batchai.models.JobCreateParameters).')
        c.argument('cluster_name', options_list=['--cluster-name', '-r'], help='If specified, the job will run on the given cluster instead of the one configured in the json file.')
        c.argument('cluster_resource_group', options_list=['--cluster-resource-group'], help='Specifies a resource group for the cluster given with --cluster-name parameter. If omitted, --resource-group value will be used.')

    with self.argument_context('batchai job create', arg_group='Azure File Share Mount') as c:
        c.argument('azure_file_share', options_list=['--afs-name'], help='Name of the Azure File Share to mount during the job execution. The File Share will be mounted only on the nodes which are executing the job. Must be used in conjunction with --storage-account-name and --storage-account-key arguments or AZURE_BATCHAI_STORAGE_ACCOUNT and AZURE_BATCHAI_STORAGE_KEY environment variables. If you need to mount more than one Azure File share, configure them in a configuration file and use --config option.')
        c.argument('afs_mount_path', options_list=['--afs-mount-path'], help='Relative mount path for Azure File Share. The File Share will be available at $AZ_BATCHAI_JOB_MOUNT_ROOT/<relative_mount_path> folder.')

    with self.argument_context('batchai job create', arg_group='Azure Storage Container Mount') as c:
        c.argument('container_name', options_list=['--bfs-name'], help='Name of Azure Storage Blob Container to mount during the job execution. The container will be mounted only on the nodes which are executing the job. Must be used in conjunction with --storage-account-name and --storage-account-key arguments or AZURE_BATCHAI_STORAGE_ACCOUNT and AZURE_BATCHAI_STORAGE_KEY environment variables. If you need to mount more than one Azure Storage container, configure them in a configuration file and use --config option.')
        c.argument('container_mount_path', options_list=['--bfs-mount-path'], help='Relative mount path for Azure Storage Blob Container. The container will be available at $AZ_BATCHAI_JOB_MOUNT_ROOT/<relative_mount_path> folder.')

    with self.argument_context('batchai job create', arg_group='Storage Account') as c:
        c.argument('account_name', options_list=['--storage-account-name'], help='Storage account name for Azure File Shares and/or Azure Storage Containers to be mounted. Related environment variable: AZURE_BATCHAI_STORAGE_ACCOUNT. Must be used in conjunction with --storage-account-key. If the key is not provided, the command will try to query the storage account key using the authenticated Azure account.')
        c.argument('account_key', options_list=['--storage-account-key'], help='Storage account key. Must be used in conjunction with --storage-account-name. Environment variable: AZURE_BATCHAI_STORAGE_KEY.')

    with self.argument_context('batchai job create', arg_group='File Server Mount') as c:
        c.argument('nfs_name', options_list=['--nfs-name'], help='Name of a file server to mount during the job execution. The NFS will be mounted only on the nodes which are executing the job. If you need to mount more than one file server, configure them in a configuration file and use --config option.')
        c.argument('nfs_resource_group', options_list=['--nfs-resource-group'], help='Resource group in which file server is created. Can be omitted if the file server and the job belong to the same resource group.')
        c.argument('nfs_mount_path', options_list=['--nfs-mount-path'], help='Relative mount path for NFS. The NFS will be available at $AZ_BATCHAI_JOB_MOUNT_ROOT/<relative_mount_path> folder.')

    with self.argument_context('batchai job list') as c:
        # Not implemented yet
        c.ignore('jobs_list_options')

    with self.argument_context('batchai job file stream') as c:
        c.argument('output_directory_id', options_list=['--output-directory-id', '-d'], help='The Id of the job\'s output directory (as specified by "id" element in outputDirectories collection in the job create parameters).')
        c.argument('file_name', options_list=['--file-name', '-f'], help='The name of the file to stream.')
        c.argument('path', options_list=['--path', '-p'], help='Relative path in the given output directory.')

    with self.argument_context('batchai job file list') as c:
        c.argument('output_directory_id', options_list=['--output-directory-id', '-d'], help='The Id of the job\'s output directory (as specified by "id" element in outputDirectories collection in the job create parameters).')
        c.argument('path', options_list=['--path', '-p'], help='Relative path in the given output directory.')
        c.argument('expiry', options_list=['--expiry', '-e'], type=int, help='Time in minutes for how long generated download URL should remain valid.')

    with self.argument_context('batchai job wait') as c:
        c.argument('check_interval_sec', options_list=['--interval'], help="Polling interval in sec.")

    with self.argument_context('batchai file-server') as c:
        c.argument('location', get_location_type(self.cli_ctx), help='Location in which to create the file server. If default location is not configured, will default to the resource group\'s location')
        c.argument('file_server_name', options_list=['--name', '-n'], help='Name of the file server.')

    with self.argument_context('batchai file-server create') as c:
        c.argument('vm_size', options_list=['--vm-size', '-s'], help='VM size.', completer=get_vm_size_completion_list)
        c.argument('json_file', options_list=['--config', '-c'], help='A path to a json file containing file server create parameters (json representation of azure.mgmt.batchai.models.FileServerCreateParameters). Note, parameters given via command line will overwrite parameters specified in the configuration file.', arg_group='Advanced')

    with self.argument_context('batchai file-server create', arg_group='Storage Disks') as c:
        c.argument('disk_count', help='Number of disks.', type=int)
        c.argument('disk_size', help='Disk size in Gb.', type=int)
        c.argument('caching_type', arg_type=get_enum_type(['none', 'readonly', 'readwrite']), help='Caching type for premium disks. If not provided via command line or in configuration file, no caching will be used.')
        c.argument('storage_sku', arg_type=get_enum_type(['Premium_LRS', 'Standard_LRS']), help='The sku of storage account to persist VM.')

    with self.argument_context('batchai file-server create', arg_group='Admin Account') as c:
        c.argument('user_name', options_list=['--user-name', '-u'], help='Name of the admin user account to be created on NFS node. If the value is not provided and no user configuration is provided in the config file, current user\'s name will be used.')
        c.argument('ssh_key', options_list=['--ssh-key', '-k'], help='SSH public key value or path. If the value is not provided and no ssh public key or password is configured in the config file the default public ssh key (~/.ssh/id_rsa.pub) of the current user will be used (if available).', completer=FilesCompleter())
        c.argument('generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing. The keys will be stored in the ~/.ssh directory.')
        c.argument('password', options_list=['--password', '-p'], help='Password.')

    with self.argument_context('batchai file-server create', arg_group='Virtual Network') as c:
        c.argument('subnet', options_list=['--subnet'], help='Resource id of a virtual network subnet to put the file server in. If not provided via command line or in configuration file, Batch AI will create a new virtual network and subnet under your subscription.')

    with self.argument_context('batchai file-server list') as c:
        # Not implemented yet
        c.ignore('file_servers_list_options')
示例#53
0
def load_arguments(self, _):
    with self.argument_context('ad') as c:
        c.argument('_subscription')  # hide global subscription param
        c.argument('owner_object_id', help="owner's object id")
        c.argument('show_mine',
                   action='store_true',
                   help='list entities owned by the current user')
        c.argument(
            'include_all',
            options_list='--all',
            action='store_true',
            help=
            'list all entities, expect long delay if under a big organization')

    with self.argument_context('ad app') as c:
        c.argument('app_id', help='application id')
        c.argument('application_object_id', options_list=('--object-id', ))
        c.argument('display_name', help='the display name of the application')
        c.argument('homepage',
                   help='the url where users can sign in and use your app.')
        c.argument('identifier',
                   options_list=['--id'],
                   help='identifier uri, application id, or object id')
        c.argument(
            'identifier_uris',
            nargs='+',
            help=
            'space-separated unique URIs that Azure AD can use for this app.')
        c.argument(
            'reply_urls',
            nargs='+',
            help=
            'space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request. The value does not need to be a physical endpoint, but must be a valid URI.'
        )
        c.argument(
            'start_date',
            help=
            "Date or datetime at which credentials become valid(e.g. '2017-01-01T01:00:00+00:00' or '2017-01-01'). Default value is current time"
        )
        c.argument(
            'end_date',
            help=
            "Date or datetime after which credentials expire(e.g. '2017-12-31T11:59:59+00:00' or '2017-12-31'). Default value is one year after current time"
        )
        c.argument(
            'available_to_other_tenants',
            help='the application can be used from any Azure AD tenants',
            arg_type=get_three_state_flag())
        c.argument(
            'key_value',
            help=
            'the value for the key credentials associated with the application'
        )
        # TODO: Update these with **enum_choice_list(...) when SDK supports proper enums
        c.argument(
            'key_type',
            help=
            'the type of the key credentials associated with the application',
            arg_type=get_enum_type(
                ['AsymmetricX509Cert', 'Password', 'Symmetric'],
                default='AsymmetricX509Cert'))
        c.argument(
            'key_usage',
            help=
            'the usage of the key credentials associated with the application.',
            arg_type=get_enum_type(['Sign', 'Verify'], default='Verify'))
        c.argument('password', help="app password, aka 'client secret'")
        c.argument('oauth2_allow_implicit_flow',
                   arg_type=get_three_state_flag(),
                   help='whether to allow implicit grant flow for OAuth2')
        c.argument(
            'required_resource_accesses',
            type=validate_file_or_dict,
            help=
            "resource scopes and roles the application requires access to. Should be in manifest json format. See examples below for details"
        )
        c.argument(
            'app_roles',
            type=validate_file_or_dict,
            help=
            "declare the roles you want to associate with your application. Should be in manifest json format. See examples below for details"
        )
        c.argument(
            'native_app',
            arg_type=get_three_state_flag(),
            help=
            "an application which can be installed on a user's device or computer"
        )
        c.argument('credential_description',
                   help="the description of the password")

    with self.argument_context('ad app owner list') as c:
        c.argument(
            'identifier',
            options_list=['--id'],
            help=
            'identifier uri, application id, or object id of the application')

    with self.argument_context('ad app permission') as c:
        c.argument('api_permissions',
                   nargs='+',
                   help='space seperated list of <resource-access-id>=<type>')
        c.argument(
            'expires',
            help=
            'Expiry date for the permissions in years. e.g. 1, 2 or "never"')
        c.argument(
            'scope',
            help=
            'Specifies the value of the scope claim that the resource application should expect in the OAuth 2.0 access token, e.g. User.Read'
        )
        c.argument('api', help='the target API to access')
        c.argument(
            'consent_type',
            arg_type=get_enum_type(ConsentType),
            default=ConsentType.all_principals.value,
            help=
            "Indicates if consent was provided by the administrator (on behalf of the organization) or by an individual."
        )
        c.argument(
            'principal_id',
            help=
            'If --consent-type is "Principal", this argument specifies the object of the user that granted consent and applies only for that user.'
        )
        c.argument('show_resource_name',
                   options_list=['--show-resource-name', '-r'],
                   arg_type=get_three_state_flag(),
                   help="show resource's display name")

    with self.argument_context('ad app permission list') as c:
        c.argument(
            'identifier',
            options_list=['--id'],
            help=
            'identifier uri, application id, or object id of the associated application'
        )

    with self.argument_context('ad sp') as c:
        c.argument('identifier',
                   options_list=['--id'],
                   help='service principal name, or object id')

    with self.argument_context('ad sp create') as c:
        c.argument(
            'identifier',
            options_list=['--id'],
            help=
            'identifier uri, application id, or object id of the associated application'
        )

    with self.argument_context('ad sp create-for-rbac') as c:
        c.argument('scopes', nargs='+')
        c.argument('role', completer=get_role_definition_name_completion_list)
        c.argument(
            'skip_assignment',
            arg_type=get_three_state_flag(),
            help=
            'Skip creating the default assignment, which allows the service principal to access resources under the current subscription'
        )
        c.argument('show_auth_for_sdk',
                   options_list='--sdk-auth',
                   help='output result in compatible with Azure SDK auth file',
                   arg_type=get_three_state_flag())

    with self.argument_context('ad sp owner list') as c:
        c.argument(
            'identifier',
            options_list=['--id'],
            help='service principal name, or object id or the service principal'
        )

    for item in ['create-for-rbac', 'credential reset']:
        with self.argument_context('ad sp {}'.format(item)) as c:
            c.argument('name', name_arg_type)
            c.argument('cert', arg_group='Credential', validator=validate_cert)
            c.argument('years', default=None, arg_group='Credential')
            c.argument(
                'end_date',
                default=None,
                arg_group='Credential',
                help=
                "Finer grain of expiry time if '--years' is insufficient, e.g. '2020-12-31T11:59:59+00:00' or '2299-12-31'"
            )
            c.argument('create_cert',
                       action='store_true',
                       arg_group='Credential')
            c.argument('keyvault', arg_group='Credential')
            c.argument(
                'append',
                action='store_true',
                help='Append the new credential instead of overwriting.')
            c.argument('credential_description',
                       help="the description of the password",
                       arg_group='Credential')

    with self.argument_context('ad sp create-for-rbac') as c:
        c.argument('password',
                   options_list=['--password', '-p'],
                   arg_group='Credential',
                   deprecate_info=c.deprecate(hide=False),
                   help="If missing, CLI will generate a strong password")

    with self.argument_context('ad sp credential reset') as c:
        c.argument('password',
                   options_list=['--password', '-p'],
                   arg_group='Credential',
                   help="If missing, CLI will generate a strong password")

    with self.argument_context('ad app credential reset') as c:
        c.argument('name',
                   options_list=['--id'],
                   help='identifier uri, application id, or object id')
        c.argument('cert',
                   arg_group='Credential',
                   validator=validate_cert,
                   help='Certificate to use for credentials')
        c.argument('password',
                   options_list=['--password', '-p'],
                   arg_group='Credential')
        c.argument(
            'years',
            type=int,
            default=None,
            arg_group='Credential',
            help='Number of years for which the credentials will be valid')
        c.argument(
            'create_cert',
            action='store_true',
            arg_group='Credential',
            help='Create a self-signed certificate to use for the credential')
        c.argument(
            'keyvault',
            arg_group='Credential',
            help=
            'Name or ID of a KeyVault to use for creating or retrieving certificates.'
        )
        c.argument('append',
                   action='store_true',
                   help='Append the new credential instead of overwriting.')

    for item in [
            'ad sp credential delete', 'ad sp credential list',
            'ad app credential delete', 'ad app credential list'
    ]:
        with self.argument_context(item) as c:
            c.argument('key_id', help='credential key id')
            c.argument('cert',
                       action='store_true',
                       help='a certificate based credential')

    with self.argument_context('ad') as c:
        c.argument('display_name', help='object\'s display name or its prefix')
        c.argument('identifier_uri',
                   help='graph application identifier, must be in uri format')
        c.argument('spn', help='service principal name')
        c.argument('upn',
                   help='user principal name, e.g. [email protected]')
        c.argument('query_filter',
                   options_list=['--filter'],
                   help='OData filter')

    with self.argument_context('ad user') as c:
        c.argument('mail_nickname',
                   help='mail alias. Defaults to user principal name')
        c.argument('force_change_password_next_login',
                   arg_type=get_three_state_flag())

    with self.argument_context('ad user get-member-groups') as c:
        c.argument(
            'upn_or_object_id',
            help=
            'The object ID or principal name of the user for which to get information'
        )
        c.argument(
            'security_enabled_only',
            action='store_true',
            help=
            'If true, only membership in security-enabled groups should be checked. Otherwise, membership in all groups should be checked.'
        )

    group_help_msg = "group's object id or display name(prefix also works if there is a unique match)"
    with self.argument_context('ad group') as c:
        for arg in VARIANT_GROUP_ID_ARGS:
            c.argument(arg,
                       options_list=['--group', '-g'],
                       validator=validate_group,
                       help=group_help_msg)

    with self.argument_context('ad group create') as c:
        c.argument('mail_nickname', help='Mail nickname')

    with self.argument_context('ad group show') as c:
        c.extra('cmd')

    member_id_help_msg = 'The object ID of the contact, group, user, or service principal'
    with self.argument_context('ad group get-member-groups') as c:
        c.argument('security_enabled_only',
                   arg_type=get_three_state_flag(),
                   default=False,
                   required=False)
        c.extra('cmd')

    with self.argument_context('ad group member add') as c:
        c.argument('url',
                   options_list='--member-id',
                   validator=validate_member_id,
                   help=member_id_help_msg)

    for item in [
            'member add', 'member check', 'member list', 'member remove',
            'delete'
    ]:
        with self.argument_context('ad group {}'.format(item)) as c:
            c.extra('cmd')

    with self.argument_context('ad group member') as c:
        c.argument('member_object_id',
                   options_list='--member-id',
                   help=member_id_help_msg)

    with self.argument_context('ad signed-in-user') as c:
        c.argument(
            'object_type',
            options_list=['--type', '-t'],
            help=
            'object type filter, e.g. "application", "servicePrincipal"  "group", etc'
        )

    with self.argument_context('role') as c:
        c.argument(
            'scope',
            help=
            'scope at which the role assignment or definition applies to, e.g., /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333, /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup, or /subscriptions/0b1f6471-1bf0-4dda-aec3-111122223333/resourceGroups/myGroup/providers/Microsoft.Compute/virtualMachines/myVM'
        )
        c.argument(
            'resource_group_name',
            options_list=['--resource-group', '-g'],
            help=
            'use it only if the role or assignment was added at the level of a resource group'
        )

    with self.argument_context('role assignment') as c:
        c.argument('role_assignment_name', options_list=['--name', '-n'])
        c.argument('role',
                   help='role name or id',
                   completer=get_role_definition_name_completion_list)
        c.argument('show_all',
                   options_list=['--all'],
                   action='store_true',
                   help='show all assignments under the current subscription')
        c.argument('include_inherited',
                   action='store_true',
                   help='include assignments applied on parent scopes')
        c.argument(
            'can_delegate',
            action='store_true',
            help=
            'when set, the assignee will be able to create further role assignments to the same role'
        )
        c.argument(
            'assignee',
            help=
            'represent a user, group, or service principal. supported format: object id, user sign-in name, or service principal name'
        )
        c.argument(
            'assignee_object_id',
            help=
            "assignee's graph object id, such as the 'principal id' from a managed service identity. Use this instead of '--assignee' to bypass graph permission issues"
        )
        c.argument('ids',
                   nargs='+',
                   help='space-separated role assignment ids')
        c.argument(
            'include_classic_administrators',
            arg_type=get_three_state_flag(),
            help=
            'list default role assignments for subscription classic administrators, aka co-admins'
        )

    time_help = (
        'The {} of the query in the format of %Y-%m-%dT%H:%M:%SZ, e.g. 2000-12-31T12:59:59Z. Defaults to {}'
    )
    with self.argument_context('role assignment list-changelogs') as c:
        c.argument('start_time',
                   help=time_help.format('start time',
                                         '1 Hour prior to the current time'))
        c.argument('end_time',
                   help=time_help.format('end time', 'the current time'))

    with self.argument_context('role definition') as c:
        c.argument('role_definition_id',
                   options_list=['--name', '-n'],
                   help='the role definition name')
        c.argument('custom_role_only',
                   arg_type=get_three_state_flag(),
                   help='custom roles only(vs. build-in ones)')
        c.argument('role_definition',
                   help="json formatted content which defines the new role.")
        c.argument('name',
                   arg_type=name_arg_type,
                   completer=get_role_definition_name_completion_list,
                   help="the role's name")

    with self.argument_context('identity') as c:
        c.argument('resource_name', arg_type=name_arg_type, id_part='name')

    with self.argument_context('identity create') as c:
        c.argument('location', get_location_type(self.cli_ctx))
        c.argument('tags', tags_type)
示例#54
0
def load_arguments(self, _):
    from argcomplete.completers import FilesCompleter

    with self.argument_context('mesh') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument('application_resource_name', options_list=('--app-name', '--application-name'), help="The name of the application", id_part='application_name')
        c.argument('service_resource_name', options_list=('--service-name'), help="The name of the service", id_part='service_resource_name')

    with self.argument_context('mesh app') as c:
        c.argument('name', options_list=('--name', '-n'), help="The name of the application", id_part='name')

    with self.argument_context('mesh service') as c:
        c.argument('service_resource_name', options_list=('--name', '-n'), help="The name of the service", id_part='service_resource_name')

    with self.argument_context('mesh service-replica') as c:
        c.argument('replica_name', options_list=('--name', '-n'), help="The name of the service replica", id_part='replica_name')

    with self.argument_context('mesh codepackage') as c:
        c.argument('code_package_name', options_list=('--name', '-n'), help="The name of the code package", id_part='code_package_name')

    with self.argument_context('mesh deployment create') as c:
        c.argument('deployment_name', options_list=('--name', '-n'), required=False,
                   help='The deployment name. Default to template file base name')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('template_file', options_list=['--template-file'], help="The full file path of creation template")
        c.argument('template_uri', options_list=['--template-uri'], help="The full file path of creation template on a http or https link")
        c.argument('input_yaml_files', options_list=['--input-yaml-files'], help="List of comma-separated yaml files or a directory which contains all the yaml files")
        c.argument('parameters', action='append', nargs='+', completer=FilesCompleter())

    with self.argument_context('mesh generate armtemplate') as c:
        c.argument('input_yaml_files', options_list=['--input-yaml-files'], required=True,
                   help="List of comma-separated yaml files or a directory which contains all the yaml files")
        c.argument('parameters', action='append', nargs='+', completer=FilesCompleter())

    with self.argument_context('mesh network') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('network_resource_name', options_list=('--name', '-n'), help="The name of the network", id_part='network_name')
        c.argument('location', arg_type=get_location_type(self.cli_ctx))

    with self.argument_context('mesh volume') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('name', options_list=('--name', '-n'), help="The name of the volume", id_part='name')
        c.argument('location', arg_type=get_location_type(self.cli_ctx))

    with self.argument_context('mesh volume create') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('template_file', options_list=['--template-file'], help="The full file path of creation template")
        c.argument('template_uri', options_list=['--template-uri'], help="The full file path of creation template on a http or https link")

    with self.argument_context('mesh secret') as c:
        c.argument('secret_resource_name', options_list=('-n', '--name'), help="The name of the secret", id_part='secret_resource_name')

    with self.argument_context('mesh secretvalue') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('secret_name', options_list=('-n', '--secret-name'), help="The name of the secret resource", id_part='secret_name')
        c.argument('secret_value_resource_name', options_list=('-v', '--version'), help="The name of the secret version", id_part='secret_value_resource_name')
        c.argument('show_value', options_list=['--show-value'], help="Pass this flag to receive the value of the secret", id_part='show_value')

    with self.argument_context('mesh gateway') as c:
        c.argument('gateway_resource_name', options_list=('-n', '--name'), help="The name of the gateway resource", id_part='gateway_resource_name')
示例#55
0
def load_arguments(self, _):

    with self.argument_context('kusto cluster list') as c:
        c.argument('resource_group_name', resource_group_name_type)

    with self.argument_context('kusto cluster show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')

    with self.argument_context('kusto cluster create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.')
        c.argument('tags', tags_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('sku', action=AddSku, nargs='+', help='The SKU of the cluster.')
        c.argument('zones', nargs='+', help='The availability zones of the cluster.')
        c.argument('trusted_external_tenants', action=AddTrustedExternalTenants, nargs='+', help='The cluster\'s '
                   'external tenants.')
        c.argument('optimized_autoscale', action=AddOptimizedAutoscale, nargs='+', help='Optimized auto scale '
                   'definition.')
        c.argument('enable_disk_encryption', arg_type=get_three_state_flag(), help='A boolean value that indicates if '
                   'the cluster\'s disks are encrypted.')
        c.argument('enable_streaming_ingest', arg_type=get_three_state_flag(), help='A boolean value that indicates if '
                   'the streaming ingest is enabled.')
        c.argument('virtual_network_configuration', action=AddVirtualNetworkConfiguration, nargs='+', help='Virtual '
                   'network definition.')
        c.argument('key_vault_properties', action=AddKeyVaultProperties, nargs='+', help='KeyVault properties for the '
                   'cluster encryption.')
        c.argument('enable_purge', arg_type=get_three_state_flag(), help='A boolean value that indicates if the purge '
                   'operations are enabled.')
        c.argument('enable_double_encryption', arg_type=get_three_state_flag(), help='A boolean value that indicates '
                   'if double encryption is enabled.')
        c.argument('type_', options_list=['--type'], arg_type=get_enum_type(['None', 'SystemAssigned']), help='The '
                   'identity type.', arg_group='Identity')
        c.argument('user_assigned_identities', type=validate_file_or_dict, help='The list of user identities '
                   'associated with the Kusto cluster. The user identity dictionary key references will be ARM '
                   'resource ids in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/prov'
                   'iders/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}\'. Expected value: '
                   'json-string/@json-file.', arg_group='Identity')

    with self.argument_context('kusto cluster update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')
        c.argument('tags', tags_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('sku', action=AddSku, nargs='+', help='The SKU of the cluster.')
        c.argument('trusted_external_tenants', action=AddTrustedExternalTenants, nargs='+', help='The cluster\'s '
                   'external tenants.')
        c.argument('optimized_autoscale', action=AddOptimizedAutoscale, nargs='+', help='Optimized auto scale '
                   'definition.')
        c.argument('enable_disk_encryption', arg_type=get_three_state_flag(), help='A boolean value that indicates if '
                   'the cluster\'s disks are encrypted.')
        c.argument('enable_streaming_ingest', arg_type=get_three_state_flag(), help='A boolean value that indicates if '
                   'the streaming ingest is enabled.')
        c.argument('virtual_network_configuration', action=AddVirtualNetworkConfiguration, nargs='+', help='Virtual '
                   'network definition.')
        c.argument('key_vault_properties', action=AddKeyVaultProperties, nargs='+', help='KeyVault properties for the '
                   'cluster encryption.')
        c.argument('enable_purge', arg_type=get_three_state_flag(), help='A boolean value that indicates if the purge '
                   'operations are enabled.')
        c.argument('enable_double_encryption', arg_type=get_three_state_flag(), help='A boolean value that indicates '
                   'if double encryption is enabled.')
        c.argument('type_', options_list=['--type'], arg_type=get_enum_type(['None', 'SystemAssigned']), help='The '
                   'identity type.', arg_group='Identity')
        c.argument('user_assigned_identities', type=validate_file_or_dict, help='The list of user identities '
                   'associated with the Kusto cluster. The user identity dictionary key references will be ARM '
                   'resource ids in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/prov'
                   'iders/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}\'. Expected value: '
                   'json-string/@json-file.', arg_group='Identity')

    with self.argument_context('kusto cluster delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')

    with self.argument_context('kusto cluster add-language-extension') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')
        c.argument('value', action=AddClustersValue, nargs='+', help='The list of language extensions.')

    with self.argument_context('kusto cluster detach-follower-database') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')
        c.argument('cluster_resource_id', type=str, help='Resource id of the cluster that follows a database owned by '
                   'this cluster.')
        c.argument('attached_database_configuration_name', type=str, help='Resource name of the attached database '
                   'configuration in the follower cluster.')

    with self.argument_context('kusto cluster diagnose-virtual-network') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')

    with self.argument_context('kusto cluster list-follower-database') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.')

    with self.argument_context('kusto cluster list-language-extension') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.')

    with self.argument_context('kusto cluster list-sku') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.')

    with self.argument_context('kusto cluster remove-language-extension') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')
        c.argument('value', action=AddClustersValue, nargs='+', help='The list of language extensions.')

    with self.argument_context('kusto cluster start') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')

    with self.argument_context('kusto cluster stop') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')

    with self.argument_context('kusto cluster wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', options_list=['--name', '-n', '--cluster-name'], type=str, help='The name of the '
                   'Kusto cluster.', id_part='name')

    with self.argument_context('kusto cluster-principal-assignment list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')

    with self.argument_context('kusto cluster-principal-assignment show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_1')

    with self.argument_context('kusto cluster-principal-assignment create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.')
        c.argument('principal_id', type=str, help='The principal ID assigned to the cluster principal. It can be a '
                   'user email, application ID, or security group name.')
        c.argument('role', arg_type=get_enum_type(['AllDatabasesAdmin', 'AllDatabasesViewer']), help='Cluster '
                   'principal role.')
        c.argument('tenant_id', type=str, help='The tenant id of the principal')
        c.argument('principal_type', arg_type=get_enum_type(['App', 'Group', 'User']), help='Principal type.')

    with self.argument_context('kusto cluster-principal-assignment update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_1')
        c.argument('principal_id', type=str, help='The principal ID assigned to the cluster principal. It can be a '
                   'user email, application ID, or security group name.')
        c.argument('role', arg_type=get_enum_type(['AllDatabasesAdmin', 'AllDatabasesViewer']), help='Cluster '
                   'principal role.')
        c.argument('tenant_id', type=str, help='The tenant id of the principal')
        c.argument('principal_type', arg_type=get_enum_type(['App', 'Group', 'User']), help='Principal type.')
        c.ignore('parameters')

    with self.argument_context('kusto cluster-principal-assignment delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_1')

    with self.argument_context('kusto cluster-principal-assignment wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_1')

    with self.argument_context('kusto database list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')

    with self.argument_context('kusto database show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')

    with self.argument_context('kusto database create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.')
        c.argument('read_write_database', action=AddReadWriteDatabase, nargs='+', help='Class representing a read '
                   'write database.', arg_group='Parameters')
        c.argument('read_only_following_database', action=AddReadOnlyFollowingDatabase, nargs='+', help='Class '
                   'representing a read only following database.', arg_group='Parameters')

    with self.argument_context('kusto database update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('read_write_database', action=AddReadWriteDatabase, nargs='+', help='Class representing a read '
                   'write database.', arg_group='Parameters')
        c.argument('read_only_following_database', action=AddReadOnlyFollowingDatabase, nargs='+', help='Class '
                   'representing a read only following database.', arg_group='Parameters')

    with self.argument_context('kusto database delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')

    with self.argument_context('kusto database add-principal') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('value', action=AddDatabasesValue, nargs='+', help='The list of Kusto database principals.')

    with self.argument_context('kusto database list-principal') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.')

    with self.argument_context('kusto database remove-principal') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('value', action=AddDatabasesValue, nargs='+', help='The list of Kusto database principals.')

    with self.argument_context('kusto database wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')

    with self.argument_context('kusto database-principal-assignment list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.')

    with self.argument_context('kusto database-principal-assignment show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_2')

    with self.argument_context('kusto database-principal-assignment create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.')
        c.argument('principal_id', type=str, help='The principal ID assigned to the database principal. It can be a '
                   'user email, application ID, or security group name.')
        c.argument('role', arg_type=get_enum_type(['Admin', 'Ingestor', 'Monitor', 'User', 'UnrestrictedViewers',
                                                   'Viewer']), help='Database principal role.')
        c.argument('tenant_id', type=str, help='The tenant id of the principal')
        c.argument('principal_type', arg_type=get_enum_type(['App', 'Group', 'User']), help='Principal type.')

    with self.argument_context('kusto database-principal-assignment update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_2')
        c.argument('principal_id', type=str, help='The principal ID assigned to the database principal. It can be a '
                   'user email, application ID, or security group name.')
        c.argument('role', arg_type=get_enum_type(['Admin', 'Ingestor', 'Monitor', 'User', 'UnrestrictedViewers',
                                                   'Viewer']), help='Database principal role.')
        c.argument('tenant_id', type=str, help='The tenant id of the principal')
        c.argument('principal_type', arg_type=get_enum_type(['App', 'Group', 'User']), help='Principal type.')
        c.ignore('parameters')

    with self.argument_context('kusto database-principal-assignment delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_2')

    with self.argument_context('kusto database-principal-assignment wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('principal_assignment_name', type=str, help='The name of the Kusto principalAssignment.',
                   id_part='child_name_2')

    with self.argument_context('kusto attached-database-configuration list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')

    with self.argument_context('kusto attached-database-configuration show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('attached_database_configuration_name', options_list=['--name', '-n',
                                                                         '--attached-database-configuration-name'],
                   type=str, help='The name of the attached database configuration.', id_part='child_name_1')

    with self.argument_context('kusto attached-database-configuration create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('attached_database_configuration_name', options_list=['--name', '-n',
                                                                         '--attached-database-configuration-name'],
                   type=str, help='The name of the attached database configuration.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('database_name', type=str, help='The name of the database which you would like to attach, use * if '
                   'you want to follow all current and future databases.')
        c.argument('cluster_resource_id', type=str, help='The resource id of the cluster where the databases you would '
                   'like to attach reside.')
        c.argument('default_principals_modification_kind', arg_type=get_enum_type(['Union', 'Replace', 'None']),
                   help='The default principals modification kind')

    with self.argument_context('kusto attached-database-configuration update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('attached_database_configuration_name', options_list=['--name', '-n',
                                                                         '--attached-database-configuration-name'],
                   type=str, help='The name of the attached database configuration.', id_part='child_name_1')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
                   validator=get_default_location_from_resource_group)
        c.argument('database_name', type=str, help='The name of the database which you would like to attach, use * if '
                   'you want to follow all current and future databases.')
        c.argument('cluster_resource_id', type=str, help='The resource id of the cluster where the databases you would '
                   'like to attach reside.')
        c.argument('default_principals_modification_kind', arg_type=get_enum_type(['Union', 'Replace', 'None']),
                   help='The default principals modification kind')
        c.ignore('parameters')

    with self.argument_context('kusto attached-database-configuration delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('attached_database_configuration_name', options_list=['--name', '-n',
                                                                         '--attached-database-configuration-name'],
                   type=str, help='The name of the attached database configuration.', id_part='child_name_1')

    with self.argument_context('kusto attached-database-configuration wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('attached_database_configuration_name', options_list=['--name', '-n',
                                                                         '--attached-database-configuration-name'],
                   type=str, help='The name of the attached database configuration.', id_part='child_name_1')

    with self.argument_context('kusto data-connection list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.')

    with self.argument_context('kusto data-connection show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('data_connection_name', options_list=['--name', '-n', '--data-connection-name'], type=str,
                   help='The name of the data connection.', id_part='child_name_2')

    with self.argument_context('kusto data-connection create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.')
        c.argument('data_connection_name', options_list=['--name', '-n', '--data-connection-name'], type=str,
                   help='The name of the data connection.')
        c.argument('event_hub_data_connection', action=AddEventHubDataConnection, nargs='+', help='Class representing '
                   'an event hub data connection.', arg_group='Parameters')
        c.argument('iot_hub_data_connection', action=AddIotHubDataConnection, nargs='+', help='Class representing an '
                   'iot hub data connection.', arg_group='Parameters')
        c.argument('event_grid_data_connection', action=AddEventGridDataConnection, nargs='+', help='Class '
                   'representing an Event Grid data connection.', arg_group='Parameters')

    with self.argument_context('kusto data-connection update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('data_connection_name', options_list=['--name', '-n', '--data-connection-name'], type=str,
                   help='The name of the data connection.', id_part='child_name_2')
        c.argument('event_hub_data_connection', action=AddEventHubDataConnection, nargs='+', help='Class representing '
                   'an event hub data connection.', arg_group='Parameters')
        c.argument('iot_hub_data_connection', action=AddIotHubDataConnection, nargs='+', help='Class representing an '
                   'iot hub data connection.', arg_group='Parameters')
        c.argument('event_grid_data_connection', action=AddEventGridDataConnection, nargs='+', help='Class '
                   'representing an Event Grid data connection.', arg_group='Parameters')

    with self.argument_context('kusto data-connection delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('data_connection_name', options_list=['--name', '-n', '--data-connection-name'], type=str,
                   help='The name of the data connection.', id_part='child_name_2')

    with self.argument_context('kusto data-connection data-connection-validation') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('data_connection_name', options_list=['--name', '-n', '--data-connection-name'], type=str,
                   help='The name of the data connection.')
        c.argument('event_hub_data_connection', action=AddEventHubDataConnection, nargs='+', help='Class representing '
                   'an event hub data connection.', arg_group='Properties')
        c.argument('iot_hub_data_connection', action=AddIotHubDataConnection, nargs='+', help='Class representing an '
                   'iot hub data connection.', arg_group='Properties')
        c.argument('event_grid_data_connection', action=AddEventGridDataConnection, nargs='+', help='Class '
                   'representing an Event Grid data connection.', arg_group='Properties')

    with self.argument_context('kusto data-connection wait') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('cluster_name', type=str, help='The name of the Kusto cluster.', id_part='name')
        c.argument('database_name', type=str, help='The name of the database in the Kusto cluster.',
                   id_part='child_name_1')
        c.argument('data_connection_name', options_list=['--name', '-n', '--data-connection-name'], type=str,
                   help='The name of the data connection.', id_part='child_name_2')
示例#56
0
def load_arguments(self, _):

    # pylint: disable=line-too-long
    # PARAMETER REGISTRATION
    name_arg_type = CLIArgumentType(options_list=['--name', '-n'],
                                    metavar='NAME')
    sku_arg_type = CLIArgumentType(
        help=
        'The pricing tiers, e.g., F1(Free), D1(Shared), B1(Basic Small), B2(Basic Medium), B3(Basic Large), S1(Standard Small), P1(Premium Small), P1V2(Premium V2 Small) etc',
        arg_type=get_enum_type([
            'F1', 'FREE', 'D1', 'SHARED', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3',
            'P1', 'P2', 'P3', 'P1V2', 'P2V2', 'P3V2'
        ]))
    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. You can configure the default using 'az configure --defaults web=<name>'"
    )

    # use this hidden arg to give a command the right instance, that functionapp commands
    # work on function app and webapp ones work on web app
    with self.argument_context('webapp') as c:
        c.ignore('app_instance')
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))
        c.argument(
            'slot',
            options_list=['--slot', '-s'],
            help=
            "the name of the slot. Default to the productions slot if not specified"
        )
        c.argument(
            'name',
            configured_default='web',
            arg_type=name_arg_type,
            completer=get_resource_name_completion_list('Microsoft.Web/sites'),
            id_part='name',
            help=
            "name of the web. You can configure the default using 'az configure --defaults web=<name>'"
        )

    with self.argument_context('appservice') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('location', arg_type=get_location_type(self.cli_ctx))

    with self.argument_context('appservice list-locations') as c:
        c.argument(
            'linux_workers_enabled',
            action='store_true',
            help='get regions which support hosting webapps on Linux workers')
        c.argument('sku', arg_type=sku_arg_type)

    with self.argument_context('appservice plan') as c:
        c.argument('name',
                   arg_type=name_arg_type,
                   help='The name of the app service plan',
                   completer=get_resource_name_completion_list(
                       'Microsoft.Web/serverFarms'),
                   configured_default='appserviceplan',
                   id_part='name')
        c.argument('number_of_workers',
                   help='Number of workers to be allocated.',
                   type=int,
                   default=1)
        c.argument('admin_site_name', help='The name of the admin web app.')

    with self.argument_context('appservice plan create') as c:
        c.argument('name',
                   options_list=['--name', '-n'],
                   help="Name of the new app service plan",
                   completer=None)
        c.argument('sku', arg_type=sku_arg_type)
        c.argument('is_linux',
                   action='store_true',
                   required=False,
                   help='host webapp on Linux worker')
    with self.argument_context('appservice plan update') as c:
        c.argument('sku', arg_type=sku_arg_type)
        c.ignore('allow_pending_state')

    with self.argument_context('webapp create') as c:
        c.argument('name',
                   options_list=['--name', '-n'],
                   help='name of the new webapp')
        c.argument('startup_file', help="Linux only. The web's startup file")
        c.argument('multicontainer_config_type',
                   options_list=['--multicontainer-config-type'],
                   help="Linux only.",
                   arg_type=get_enum_type(MULTI_CONTAINER_TYPES))
        c.argument(
            'multicontainer_config_file',
            options_list=['--multicontainer-config-file'],
            help=
            "Linux only. Config file for multicontainer apps. (local or remote)"
        )
        c.argument(
            'runtime',
            options_list=['--runtime', '-r'],
            help=
            "canonicalized web runtime in the format of Framework|Version, e.g. \"PHP|5.6\". Use 'az webapp list-runtimes' for available list"
        )  # TODO ADD completer
        c.argument(
            'plan',
            options_list=['--plan', '-p'],
            configured_default='appserviceplan',
            completer=get_resource_name_completion_list(
                'Microsoft.Web/serverFarms'),
            help=
            "name or resource id of the app service plan. Use 'appservice plan create' to get one"
        )

    with self.argument_context('webapp show') as c:
        c.argument('name', arg_type=webapp_name_arg_type)

    with self.argument_context('webapp list-runtimes') as c:
        c.argument('linux',
                   action='store_true',
                   help='list runtime stacks for linux based webapps')

    with self.argument_context('webapp traffic-routing') as c:
        c.argument(
            'distribution',
            options_list=['--distribution', '-d'],
            nargs='+',
            help=
            'space-separated slot routings in a format of <slot-name>=<percentage> e.g. staging=50. Unused traffic percentage will go to the Production slot'
        )

    with self.argument_context('webapp update') as c:
        c.argument('client_affinity_enabled',
                   help="Enables sending session affinity cookies.",
                   arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'https_only',
            help="Redirect all traffic made to an app using HTTP to HTTPS.",
            arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'force_dns_registration',
            help="If true, web app hostname is force registered with DNS",
            arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'skip_custom_domain_verification',
            help=
            "If true, custom (non *.azurewebsites.net) domains associated with web app are not verified",
            arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'ttl_in_seconds',
            help="Time to live in seconds for web app's default domain name",
            arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'skip_dns_registration',
            help=
            "If true web app hostname is not registered with DNS on creation",
            arg_type=get_three_state_flag(return_label=True))

    with self.argument_context('webapp browse') as c:
        c.argument(
            'logs',
            options_list=['--logs', '-l'],
            action='store_true',
            help=
            'Enable viewing the log stream immediately after launching the web app'
        )
    with self.argument_context('webapp delete') as c:
        c.argument('keep_empty_plan',
                   action='store_true',
                   help='keep empty app service plan')
        c.argument('keep_metrics',
                   action='store_true',
                   help='keep app metrics')
        c.argument('keep_dns_registration',
                   action='store_true',
                   help='keep DNS registration')

    for scope in ['webapp', 'functionapp']:
        with self.argument_context(scope + ' create') as c:
            c.argument(
                'deployment_container_image_name',
                options_list=['--deployment-container-image-name', '-i'],
                help=
                'Linux only. Container image name from Docker Hub, e.g. publisher/image-name:tag'
            )
            c.argument('deployment_local_git',
                       action='store_true',
                       options_list=['--deployment-local-git', '-l'],
                       help='enable local git')
            c.argument('deployment_zip',
                       options_list=['--deployment-zip', '-z'],
                       help='perform deployment using zip file')
            c.argument(
                'deployment_source_url',
                options_list=['--deployment-source-url', '-u'],
                help='Git repository URL to link with manual integration')
            c.argument('deployment_source_branch',
                       options_list=['--deployment-source-branch', '-b'],
                       help='the branch to deploy')
        with self.argument_context(scope + ' config ssl bind') as c:
            c.argument('ssl_type',
                       help='The ssl cert type',
                       arg_type=get_enum_type(['SNI', 'IP']))
        with self.argument_context(scope + ' config ssl upload') as c:
            c.argument('certificate_password', help='The ssl cert password')
            c.argument('certificate_file',
                       type=file_type,
                       help='The filepath for the .pfx file')
        with self.argument_context(scope + ' config ssl') as c:
            c.argument('certificate_thumbprint',
                       help='The ssl cert thumbprint')
        with self.argument_context(scope + ' config appsettings') as c:
            c.argument(
                'settings',
                nargs='+',
                help=
                "space-separated app settings in a format of <name>=<value>")
            c.argument('setting_names',
                       nargs='+',
                       help="space-separated app setting names")

        with self.argument_context(scope + ' config hostname') as c:
            c.argument(
                'hostname',
                completer=get_hostname_completion_list,
                help="hostname assigned to the site, such as custom domains",
                id_part='child_name_1')
        with self.argument_context(scope + ' deployment user') as c:
            c.argument('user_name', help='user name')
            c.argument('password',
                       help='password, will prompt if not specified')
        with self.argument_context(scope + ' deployment source') as c:
            c.argument(
                'manual_integration',
                action='store_true',
                help='disable automatic sync between source control and web')
            c.argument(
                'repo_url',
                options_list=['--repo-url', '-u'],
                help=
                'repository url to pull the latest source from, e.g. https://github.com/foo/foo-web'
            )
            c.argument('branch', help='the branch name of the repository')
            c.argument('private_repo_username',
                       arg_group='VSTS CD Provider',
                       help='Username for the private repository')
            c.argument('private_repo_password',
                       arg_group='VSTS CD Provider',
                       help='Password for the private repository')
            c.argument(
                'cd_app_type',
                arg_group='VSTS CD Provider',
                help=
                'Web application framework you used to develop your app. Default is AspNet.',
                arg_type=get_enum_type(
                    ['AspNet', 'AspNetCore', 'NodeJS', 'PHP', 'Python']))
            c.argument(
                'app_working_dir',
                arg_group='VSTS CD Provider',
                help=
                'Working directory of the application. Default will be root of the repo'
            )
            c.argument('nodejs_task_runner',
                       arg_group='VSTS CD Provider',
                       help='Task runner for nodejs. Default is None',
                       arg_type=get_enum_type(['None', 'Gulp', 'Grunt']))
            c.argument(
                'python_framework',
                arg_group='VSTS CD Provider',
                help='Framework used for Python application. Default is Django',
                arg_type=get_enum_type(['Bottle', 'Django', 'Flask']))
            c.argument(
                'python_version',
                arg_group='VSTS CD Provider',
                help=
                'Python version used for application. Default is Python 3.5.3 x86',
                arg_type=get_enum_type([
                    'Python 2.7.12 x64', 'Python 2.7.12 x86',
                    'Python 2.7.13 x64', 'Python 2.7.13 x86',
                    'Python 3.5.3 x64', 'Python 3.5.3 x86', 'Python 3.6.0 x64',
                    'Python 3.6.0 x86', 'Python 3.6.2 x64', 'Python 3.6.1 x86'
                ]))
            c.argument(
                'cd_project_url',
                arg_group='VSTS CD Provider',
                help=
                'URL of the Visual Studio Team Services (VSTS) project to use for continuous delivery. URL should be in format https://<accountname>.visualstudio.com/<projectname>'
            )
            c.argument(
                'cd_account_create',
                arg_group='VSTS CD Provider',
                help=
                "To create a new Visual Studio Team Services (VSTS) account if it doesn't exist already",
                action='store_true')
            c.argument(
                'test',
                arg_group='VSTS CD Provider',
                help=
                'Name of the web app to be used for load testing. If web app is not available, it will be created. Default: Disable'
            )
            c.argument(
                'slot_swap',
                arg_group='VSTS CD Provider',
                help=
                'Name of the slot to be used for deployment and later promote to production. If slot is not available, it will be created. Default: Not configured'
            )
            c.argument('repository_type',
                       help='repository type',
                       arg_type=get_enum_type([
                           'git', 'mercurial', 'vsts', 'github', 'externalgit',
                           'localgit'
                       ]))
            c.argument('git_token',
                       help='Git access token required for auto sync')
        with self.argument_context(scope + ' identity') as c:
            c.argument('scope',
                       help="The scope the managed identity has access to")
            c.argument(
                'role',
                help="Role name or id the managed identity will be assigned")

        with self.argument_context(scope +
                                   ' deployment source config-zip') as c:
            c.argument('src', help='a zip file path for deployment')

        with self.argument_context(scope + ' config appsettings list') as c:
            c.argument('name', arg_type=webapp_name_arg_type, id_part=None)

        with self.argument_context(scope + ' config hostname list') as c:
            c.argument('webapp_name',
                       arg_type=webapp_name_arg_type,
                       id_part=None,
                       options_list='--webapp-name')

    with self.argument_context('webapp config connection-string list') as c:
        c.argument('name', arg_type=webapp_name_arg_type, id_part=None)

    with self.argument_context('webapp config hostname') as c:
        c.argument(
            'webapp_name',
            help=
            "webapp name. You can configure the default using 'az configure --defaults web=<name>'",
            configured_default='web',
            completer=get_resource_name_completion_list('Microsoft.Web/sites'),
            id_part='name')
    with self.argument_context('webapp deployment container config') as c:
        c.argument('enable',
                   options_list=['--enable-cd', '-e'],
                   help='enable/disable continuous deployment',
                   arg_type=get_enum_type(['true', 'false']))
    with self.argument_context('webapp deployment slot') as c:
        c.argument('slot', help='the name of the slot')
        c.argument(
            'webapp',
            arg_type=name_arg_type,
            completer=get_resource_name_completion_list('Microsoft.Web/sites'),
            help='Name of the webapp',
            id_part='name')
        c.argument('auto_swap_slot',
                   help='target slot to auto swap',
                   default='production')
        c.argument('disable', help='disable auto swap', action='store_true')
        c.argument('target_slot',
                   help="target slot to swap, default to 'production'")
    with self.argument_context('webapp deployment slot create') as c:
        c.argument(
            'configuration_source',
            help=
            "source slot to clone configurations from. Use webapp's name to refer to the production slot"
        )
    with self.argument_context('webapp deployment slot swap') as c:
        c.argument(
            'action',
            help=
            "swap types. use 'preview' to apply target slot's settings on the source slot first; use 'swap' to complete it; use 'reset' to reset the swap",
            arg_type=get_enum_type(['swap', 'preview', 'reset']))
    with self.argument_context('webapp log config') as c:
        c.argument('application_logging',
                   help='configure application logging to file system',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument('detailed_error_messages',
                   help='configure detailed error messages',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument('failed_request_tracing',
                   help='configure failed request tracing',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument('level',
                   help='logging level',
                   arg_type=get_enum_type(
                       ['error', 'warning', 'information', 'verbose']))
        c.argument('web_server_logging',
                   help='configure Web server logging',
                   arg_type=get_enum_type(['off', 'filesystem']))
        c.argument(
            'docker_container_logging',
            help='configure gathering STDOUT and STDERR output from container',
            arg_type=get_enum_type(['off', 'filesystem']))

    with self.argument_context('webapp log tail') as c:
        c.argument(
            'provider',
            help=
            "By default all live traces configured by 'az webapp log config' will be shown, but you can scope to certain providers/folders, e.g. 'application', 'http', etc. For details, check out https://github.com/projectkudu/kudu/wiki/Diagnostic-Log-Stream"
        )
    with self.argument_context('webapp log download') as c:
        c.argument('log_file',
                   default='webapp_logs.zip',
                   type=file_type,
                   completer=FilesCompleter(),
                   help='the downloaded zipped log file path')

    for scope in ['appsettings', 'connection-string']:
        with self.argument_context('webapp config ' + scope) as c:
            c.argument(
                'settings',
                nargs='+',
                help="space-separated {} in a format of <name>=<value>".format(
                    scope))
            c.argument(
                'slot_settings',
                nargs='+',
                help="space-separated slot {} in a format of <name>=<value>".
                format(scope))
            c.argument('setting_names',
                       nargs='+',
                       help="space-separated {} names".format(scope))

    with self.argument_context('webapp config connection-string') as c:
        c.argument('connection_string_type',
                   options_list=['--connection-string-type', '-t'],
                   help='connection string type',
                   arg_type=get_enum_type(ConnectionStringType))

    with self.argument_context('webapp config container') as c:
        c.argument('docker_registry_server_url',
                   options_list=['--docker-registry-server-url', '-r'],
                   help='the container registry server url')
        c.argument(
            'docker_custom_image_name',
            options_list=['--docker-custom-image-name', '-c', '-i'],
            help='the container custom image name and optionally the tag name')
        c.argument('docker_registry_server_user',
                   options_list=['--docker-registry-server-user', '-u'],
                   help='the container registry server username')
        c.argument('docker_registry_server_password',
                   options_list=['--docker-registry-server-password', '-p'],
                   help='the container registry server password')
        c.argument('websites_enable_app_service_storage',
                   options_list=['--enable-app-service-storage', '-t'],
                   help='enables platform storage (custom container only)',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument('multicontainer_config_type',
                   options_list=['--multicontainer-config-type'],
                   help='config type',
                   arg_type=get_enum_type(MULTI_CONTAINER_TYPES))
        c.argument('multicontainer_config_file',
                   options_list=['--multicontainer-config-file'],
                   help="config file for multicontainer apps")
        c.argument(
            'show_multicontainer_config',
            action='store_true',
            help='shows decoded config if a multicontainer config is set')

    with self.argument_context('webapp config set') as c:
        c.argument('remote_debugging_enabled',
                   help='enable or disable remote debugging',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument('web_sockets_enabled',
                   help='enable or disable web sockets',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'always_on',
            help=
            'ensure webapp gets loaded all the time, rather unloaded after been idle. Recommended when you have continuous web jobs running',
            arg_type=get_three_state_flag(return_label=True))
        c.argument('auto_heal_enabled',
                   help='enable or disable auto heal',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument('use32_bit_worker_process',
                   options_list=['--use-32bit-worker-process'],
                   help='use 32 bits worker process or not',
                   arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'php_version',
            help=
            'The version used to run your web app if using PHP, e.g., 5.5, 5.6, 7.0'
        )
        c.argument(
            'python_version',
            help=
            'The version used to run your web app if using Python, e.g., 2.7, 3.4'
        )
        c.argument(
            'net_framework_version',
            help=
            "The version used to run your web app if using .NET Framework, e.g., 'v4.0' for .NET 4.6 and 'v3.0' for .NET 3.5"
        )
        c.argument(
            'linux_fx_version',
            help=
            "The runtime stack used for your linux-based webapp, e.g., \"RUBY|2.3\", \"NODE|6.6\", \"PHP|5.6\", \"DOTNETCORE|1.1.0\". See https://aka.ms/linux-stacks for more info."
        )
        c.argument(
            'java_version',
            help=
            "The version used to run your web app if using Java, e.g., '1.7' for Java 7, '1.8' for Java 8"
        )
        c.argument('java_container',
                   help="The java container, e.g., Tomcat, Jetty")
        c.argument(
            'java_container_version',
            help="The version of the java container, e.g., '8.0.23' for Tomcat"
        )
        c.argument(
            'min_tls_version',
            help=
            "The minimum version of TLS required for SSL requests, e.g., '1.0', '1.1', '1.2'"
        )
        c.argument(
            'http20_enabled',
            help=
            "configures a web site to allow clients to connect over http2.0.",
            arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'app_command_line',
            options_list=['--startup-file'],
            help=
            "The startup file for linux hosted web apps, e.g. 'process.json' for Node.js web"
        )

    with self.argument_context('webapp config backup') as c:
        c.argument('storage_account_url',
                   help='URL with SAS token to the blob storage container',
                   options_list=['--container-url'])
        c.argument('webapp_name', help='The name of the webapp')
        c.argument('db_name',
                   help='Name of the database in the backup',
                   arg_group='Database')
        c.argument('db_connection_string',
                   help='Connection string for the database in the backup',
                   arg_group='Database')
        c.argument('db_type',
                   help='Type of database in the backup',
                   arg_group='Database',
                   arg_type=get_enum_type(DatabaseType))

    with self.argument_context('webapp config backup create') as c:
        c.argument(
            'backup_name',
            help=
            'Name of the backup. If unspecified, the backup will be named with the webapp name and a timestamp'
        )

    with self.argument_context('webapp config backup update') as c:
        c.argument(
            'backup_name',
            help=
            'Name of the backup. If unspecified, the backup will be named with the webapp name and a timestamp'
        )
        c.argument(
            'frequency',
            help=
            'How often to backup. Use a number followed by d or h, e.g. 5d = 5 days, 2h = 2 hours'
        )
        c.argument('keep_at_least_one_backup',
                   help='Always keep one backup, regardless of how old it is',
                   options_list=['--retain-one'],
                   arg_type=get_three_state_flag(return_label=True))
        c.argument(
            'retention_period_in_days',
            help=
            'How many days to keep a backup before automatically deleting it. Set to 0 for indefinite retention',
            options_list=['--retention'])

    with self.argument_context('webapp config backup restore') as c:
        c.argument('backup_name', help='Name of the backup to restore')
        c.argument(
            'target_name',
            help=
            'The name to use for the restored webapp. If unspecified, will default to the name that was used when the backup was created'
        )
        c.argument(
            'overwrite',
            help=
            'Overwrite the source webapp, if --target-name is not specified',
            action='store_true')
        c.argument('ignore_hostname_conflict',
                   help='Ignores custom hostnames stored in the backup',
                   action='store_true')

    with self.argument_context('webapp auth update') as c:
        c.argument('enabled', arg_type=get_three_state_flag(return_label=True))
        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))
        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,
                   help="Hours, must be formattable into a float")
        c.argument('allowed_external_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('allowed_audiences',
                   nargs='+',
                   options_list=['--aad-allowed-token-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_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',
                   help='Twitter Application client secret')
        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_oauth_scopes',
            nargs='+',
            help="One or more Google authentication scopes (space-delimited).",
            arg_group='Google')
        c.argument(
            'microsoft_account_client_id',
            arg_group='Microsoft',
            help=
            "AAD V2 Application ID to integrate Microsoft account Sign-in into your web app"
        )
        c.argument('microsoft_account_client_secret',
                   arg_group='Microsoft',
                   help='AAD V2 Application client secret')
        c.argument(
            'microsoft_account_oauth_scopes',
            nargs='+',
            help=
            "One or more Microsoft authentification scopes (space-delimited).",
            arg_group='Microsoft')

    with self.argument_context('functionapp') as c:
        c.ignore('app_instance', 'slot')
        c.argument('name',
                   arg_type=name_arg_type,
                   id_part='name',
                   help='name of the function app')
    with self.argument_context('functionapp config hostname') as c:
        c.argument('webapp_name',
                   arg_type=name_arg_type,
                   id_part='name',
                   help='name of the function app')
    with self.argument_context('functionapp create') as c:
        c.argument(
            'plan',
            options_list=['--plan', '-p'],
            configured_default='appserviceplan',
            completer=get_resource_name_completion_list(
                'Microsoft.Web/serverFarms'),
            help=
            "name or resource id of the function app service plan. Use 'appservice plan create' to get one"
        )
        c.argument('new_app_name',
                   options_list=['--name', '-n'],
                   help='name of the new function app')
        c.argument(
            'storage_account',
            options_list=['--storage-account', '-s'],
            help=
            'Provide a string value of a Storage Account in the provided Resource Group. Or Resource ID of a Storage Account in a different Resource Group'
        )
        c.argument(
            'consumption_plan_location',
            options_list=['--consumption-plan-location', '-c'],
            help=
            "Geographic location where Function App will be hosted. Use 'functionapp list-consumption-locations' to view available locations."
        )
    # For commands with shared impl between webapp and functionapp and has output, we apply type validation to avoid confusions
    with self.argument_context('functionapp show') as c:
        c.argument('name', arg_type=name_arg_type)
    with self.argument_context('functionapp config appsettings') as c:
        c.argument(
            'slot_settings',
            nargs='+',
            help=
            "space-separated slot app settings in a format of <name>=<value>")
示例#57
0
    def _complex_params(command_group):
        with self.argument_context(
                '{} server create'.format(command_group)) as c:
            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.'
            )
            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('location',
                       arg_type=get_location_type(self.cli_ctx),
                       required=False)
            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.'
            )

        with self.argument_context(
                '{} server restore'.format(command_group)) as c:
            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',
                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.'
            )
            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('mysql server replica') as c:
            c.argument(
                'source_server',
                options_list=['--source-server', '-s'],
                help=
                'The name or resource ID of the master server to the create replica for.'
            )

        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')
示例#58
0
def load_arguments(self, _):

    for scope in ['sql vm', 'sql vm group']:
        with self.argument_context(scope) as c:
            c.argument('tags', tags_type)

    ###############################################
    #    sql virtual machine groups params        #
    ###############################################

    with self.argument_context('sql vm group') as c:
        c.argument('sql_virtual_machine_group_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='Name of the SQL virtual machine group.')
        c.argument(
            'sql_image_offer',
            options_list=['--image-offer', '-i'],
            help=
            'SQL image offer. Examples may include SQL2016-WS2016, SQL2017-WS2016.'
        )
        c.argument('sql_image_sku',
                   options_list=['--image-sku', '-s'],
                   help='SQL image sku.',
                   arg_type=get_enum_type(SqlVmGroupImageSku))
        c.argument(
            'location',
            help=
            'Location. If not provided, group will be created in the same reosurce group location.'
            'You can configure the default location using `az configure --defaults location=<location>`.',
            arg_type=get_location_type(self.cli_ctx),
            validator=get_default_location_from_resource_group)

    with self.argument_context('sql vm group',
                               arg_group='WSFC Domain Profile') as c:
        c.argument('domain_fqdn',
                   options_list=['--domain-fqdn', '-f'],
                   help='Fully qualified name of the domain.')
        c.argument(
            'cluster_operator_account',
            options_list=['--operator-acc', '-p'],
            help=
            'Account name used for operating cluster i.e. will be part of administrators group on all the participating virtual machines in the cluster.'
        )
        c.argument(
            'sql_service_account',
            options_list=['--service-acc', '-e'],
            help=
            'Account name under which SQL service will run on all participating SQL virtual machines in the cluster.'
        )
        c.argument('storage_account_url',
                   options_list=['--storage-account', '-u'],
                   help='Storage account url of the witness storage account.')
        c.argument('storage_account_key',
                   options_list=['--sa-key', '-k'],
                   help='Primary key of the witness storage account.')
        c.argument(
            'cluster_bootstrap_account',
            options_list=['--bootstrap-acc'],
            help=
            'Account name used for creating cluster (at minimum needs permissions to \'Create Computer Objects\' in domain).'
        )
        c.argument('file_share_witness_path',
                   options_list=['--fsw-path'],
                   help='Optional path for fileshare witness.')
        c.argument(
            'ou_path',
            help=
            'Organizational Unit path in which the nodes and cluster will be present. Example: OU=WSCluster,DC=testdomain,DC=com'
        )

    ###############################################
    #    availability group listener params       #
    ###############################################

    with self.argument_context('sql vm group ag-listener') as c:
        c.argument('availability_group_listener_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='Name of the availability group listener.')
        c.argument('sql_virtual_machine_group_name',
                   options_list=['--group-name', '-r'],
                   help='Name of the SQL virtual machine group.',
                   id_part=None)
        c.argument('port',
                   options_list=['--port', '-p'],
                   help='Listener port.',
                   type=int)
        c.argument(
            'availability_group_name',
            options_list=['--ag-name', '-a'],
            help='Name of the availability group. Please refer to '
            'https://docs.microsoft.com/sql/database-engine/availability-groups/windows/use-the-availability-group-wizard-sql-server-management-studio?view=sql-server-2017 '
            'to create and availability group')

    with self.argument_context('sql vm group ag-listener',
                               arg_group='Load Balancer Configuration') as c:
        c.argument(
            'ip_address',
            options_list=['--ip-address', '-i'],
            help='Private IP address bound to the availability group listener.'
        )
        c.argument(
            'subnet_resource_id',
            options_list=['--subnet', '-u'],
            validator=validate_subnet,
            help=
            'The name or resource id of the subnet to include in the private IP.'
        )
        c.argument(
            'vnet_name',
            options_list=['--vnet-name'],
            help=
            'Name of the virtual network. Provide only if name of the subnet has been provided.'
        )
        c.argument('public_ip_address_resource_id',
                   options_list=['--public-ip', '-c'],
                   validator=validate_public_ip_address,
                   help='Name or resource ID of the public IP.')
        c.argument('load_balancer_resource_id',
                   options_list=['--load-balancer', '-b'],
                   validator=validate_load_balancer,
                   help='Name or resource ID of the load balancer.')
        c.argument('probe_port',
                   options_list=['--probe-port', '-e'],
                   help='Probe port.',
                   type=int)
        c.argument(
            'sql_virtual_machine_instances',
            options_list=['--sqlvms', '-q'],
            nargs='+',
            validator=validate_sqlvm_list,
            help=
            'Space-separated list of SQL virtual machine instance name or resource IDs that are enrolled into the availability group.'
        )

    ###############################################
    #      sql virtual machine params             #
    ###############################################

    with self.argument_context('sql vm') as c:
        c.argument('sql_virtual_machine_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='Name of the SQL virtual machine.')
        c.argument(
            'location',
            help=
            'Location. If not provided, virtual machine should be in the same region of resource group.'
            'You can configure the default location using `az configure --defaults location=<location>`.',
            arg_type=get_location_type(self.cli_ctx),
            validator=get_default_location_from_resource_group)
        c.argument(
            'expand',
            help=
            'Get the SQLIaaSExtension configuration settings. To view all settings, use *. To select only a few, the settings must be space-separted.',
            nargs='+',
            validator=validate_expand,
            arg_type=get_enum_type([
                '*', 'AutoBackupSettings', 'AutoPatchingSettings',
                'KeyVaultCredentialSettings',
                'ServerConfigurationsManagementSettings'
            ]))
        c.argument(
            'sql_management_mode',
            help=
            'SQL Server management type. If NoAgent selected, please provide --image-sku and --offer-type.',
            options_list=['--sql-mgmt-type'],
            validator=validate_sqlmanagement,
            arg_type=get_enum_type(SqlManagementMode))

    with self.argument_context('sql vm', arg_group='SQL Server License') as c:
        c.argument('sql_server_license_type',
                   help='SQL Server license type.',
                   options_list=['--license-type', '-i'],
                   arg_type=get_enum_type(SqlServerLicenseType))
        c.argument('sql_image_sku',
                   options_list=['--image-sku'],
                   help='SQL image sku.',
                   arg_type=get_enum_type(SqlImageSku))
        c.argument(
            'sql_image_offer',
            options_list=['--image-offer'],
            help=
            'SQL image offer. Examples include SQL2008R2-WS2008, SQL2008-WS2008.'
        )

    with self.argument_context('sql vm add-to-group') as c:
        c.argument(
            'sql_virtual_machine_group_resource_id',
            options_list=['--sqlvm-group', '-r'],
            validator=validate_sqlvm_group,
            help=
            'Name or resource ID of the SQL virtual machine group. If only name provided, SQL virtual machine group should be in the same '
            'resource group of the SQL virtual machine.')
        c.argument('sql_virtual_machine_name',
                   id_part='name',
                   help="Name of the SQL virtual machine.")

    with self.argument_context('sql vm remove-from-group') as c:
        c.argument('sql_virtual_machine_name',
                   id_part='name',
                   help="Name of the SQL virtual machine.")

    with self.argument_context('sql vm update') as c:
        c.argument(
            'sql_management_mode',
            help=
            'SQL Server management type. Updates from LightWeight to Full.',
            options_list=['--sql-mgmt-type'],
            arg_type=get_enum_type(['Full']))
        c.argument(
            'prompt',
            options_list=['--yes', '-y'],
            help="Do not prompt for confirmation. Requires --sql-mgmt-type.")

    with self.argument_context('sql vm add-to-group',
                               arg_group='WSFC Domain Credentials') as c:
        c.argument(
            'cluster_bootstrap_account_password',
            options_list=['-b', '--bootstrap-acc-pwd'],
            help=
            'Password for the cluster bootstrap account if provided in the SQL virtual machine group.'
        )
        c.argument(
            'cluster_operator_account_password',
            options_list=['--operator-acc-pwd', '-p'],
            help=
            'Password for the cluster operator account provided in the SQL virtual machine group.'
        )
        c.argument(
            'sql_service_account_password',
            options_list=['--service-acc-pwd', '-s'],
            help=
            'Password for the SQL service account provided in the SQL virtual machine group.'
        )

    with self.argument_context('sql vm',
                               arg_group='Auto Patching Settings') as c:
        c.argument(
            'enable_auto_patching',
            help=
            'Enable or disable autopatching on SQL virtual machine. If any autopatching settings provided, parameter automatically sets to true.',
            arg_type=get_three_state_flag())
        c.argument('day_of_week',
                   help='Day of week to apply the patch on.',
                   arg_type=get_enum_type(DayOfWeek))
        c.argument(
            'maintenance_window_starting_hour',
            type=int,
            options_list=['--maintenance-window-start-hour'],
            help=
            'Hour of the day when patching is initiated. Local VM time 0-23 hours.'
        )
        c.argument('maintenance_window_duration',
                   type=int,
                   help='Duration of patching. 30-180 minutes.')

    with self.argument_context('sql vm',
                               arg_group='Auto Backup Settings') as c:
        c.argument(
            'enable_auto_backup',
            help=
            'Enable or disable autobackup on SQL virtual machine. If any backup settings provided, parameter automatically sets to true.',
            arg_type=get_three_state_flag())
        c.argument(
            'enable_encryption',
            help=' Enable encryption for backup on SQL virtual machine.',
            arg_type=get_three_state_flag())
        c.argument('retention_period',
                   type=int,
                   help='Retention period of backup. 1-30 days.')
        c.argument('storage_account_url',
                   options_list=['--storage-account'],
                   help='Storage account url where backup will be taken to.')
        c.argument('storage_access_key',
                   options_list=['--sa-key'],
                   help='Storage account key where backup will be taken to.')
        c.argument('backup_password',
                   options_list=['--backup-pwd'],
                   help='Password for encryption on backup.')
        c.argument('backup_system_dbs',
                   help='Include system databases on backup.',
                   arg_type=get_three_state_flag())
        c.argument('backup_schedule_type',
                   help='Backup schedule type.',
                   arg_type=get_enum_type(BackupScheduleType))
        c.argument(
            'full_backup_frequency',
            help=
            'Frequency of full backups. In both cases, full backups begin during the next scheduled time window.',
            arg_type=get_enum_type(FullBackupFrequencyType))
        c.argument(
            'full_backup_start_time',
            type=int,
            options_list=['--full-backup-start-hour'],
            help=
            'Start time of a given day during which full backups can take place. 0-23 hours.'
        )
        c.argument(
            'full_backup_window_hours',
            type=int,
            options_list=['--full-backup-duration'],
            help=
            'Duration of the time window of a given day during which full backups can take place. 1-23 hours.'
        )
        c.argument('log_backup_frequency',
                   type=int,
                   help='Frequency of log backups. 5-60 minutes.')

    with self.argument_context('sql vm',
                               arg_group='Key Vault Credential Settings') as c:
        c.argument(
            'enable_key_vault_credential',
            help=
            'Enable or disable key vault credential setting. If any key vault settings provided, parameter automatically sets to true.',
            arg_type=get_three_state_flag())
        c.argument('credential_name', help='Credential name')
        c.argument('azure_key_vault_url',
                   options_list=['--key-vault'],
                   help='Azure Key Vault url.')
        c.argument('service_principal_name',
                   options_list=['--sp-name'],
                   help='Service principal name to access key vault.')
        c.argument('service_principal_secret',
                   options_list=['--sp-secret'],
                   help='Service principal name secret to access key vault.')

    with self.argument_context(
            'sql vm', arg_group='SQL Connectivity Update Settings') as c:
        c.argument('connectivity_type',
                   help='SQL Server connectivity option.',
                   arg_type=get_enum_type(ConnectivityType))
        c.argument('port', help='SQL Server port.', type=int)
        c.argument('sql_auth_update_username',
                   help='SQL Server sysadmin login to create.')
        c.argument('sql_auth_update_password',
                   options_list=['--sql-auth-update-pwd'],
                   help='SQL Server sysadmin login password.')

    with self.argument_context(
            'sql vm', arg_group='SQL Workload Type Update Settings') as c:
        c.argument('sql_workload_type',
                   help='SQL Server workload type.',
                   arg_type=get_enum_type(SqlWorkloadType))

    with self.argument_context('sql vm',
                               arg_group='SQL Storage Update Settings') as c:
        c.argument('disk_count', help='Virtual machine disk count.', type=int)
        c.argument('disk_configuration_type',
                   help='Disk configuration to apply to SQL Server.',
                   arg_type=get_enum_type(DiskConfigurationType))

    with self.argument_context('sql vm', arg_group='Additional Features') as c:
        c.argument('enable_r_services',
                   help='Enable or disable R services (SQL 2016 onwards).',
                   arg_type=get_three_state_flag())
示例#59
0
    def _complex_params(command_group):
        with self.argument_context(
                '{} server create'.format(command_group)) as c:
            c.argument(
                'sku_name',
                options_list=['--sku-name'],
                required=True,
                help=
                'The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.'
            )

            c.argument('backup_retention',
                       type=int,
                       options_list=['--backup-retention'],
                       help='The number of days a backup is retained.')
            c.argument('geo_redundant_backup',
                       options_list=['--geo-redundant-backup'],
                       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('administrator_login',
                       required=True,
                       arg_group='Authentication')
            c.argument('administrator_login_password',
                       arg_group='Authentication')

            c.argument('location',
                       arg_type=get_location_type(self.cli_ctx),
                       required=False)
            c.argument('version', help='Server 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, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.'
            )

        with self.argument_context(
                '{} server restore'.format(command_group)) as c:
            c.argument(
                'source_server',
                options_list=['--source-server', '-s'],
                help='The name or ID of the source server to restore from.')
            c.argument(
                'restore_point_in_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, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.'
            )
            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 max days of retention, unit is days.')
            c.argument('geo_redundant_backup',
                       options_list=['--geo-redundant-backup'],
                       help='Enable Geo-redundant or not for server backup.')

        with self.argument_context('mysql server replica') as c:
            c.argument(
                'source_server',
                options_list=['--source-server', '-s'],
                help=
                'The name or ID of the master server to create replica for.')

        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')
示例#60
0
def load_arguments(self, _):

    from azure.cli.core.commands.parameters import tags_type
    from azure.cli.core.commands.validators import get_default_location_from_resource_group

    with self.argument_context('apim') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('tags', tags_type)
        c.argument('service_name',
                   options_list=['--name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument('name',
                   options_list=['--name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument('location',
                   validator=get_default_location_from_resource_group)

    with self.argument_context('apim create') as c:
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument(
            'publisher_name',
            help=
            'The name of your organization for use in the developer portal and e-mail notifications.',
            required=True)
        c.argument(
            'publisher_email',
            help='The e-mail address to receive all system notifications.')
        c.argument(
            'enable_client_certificate',
            arg_type=get_three_state_flag(),
            help=
            'Enforces a client certificate to be presented on each request to the gateway and also enables the ability to authenticate the certificate in the policy on the gateway.'
        )
        c.argument('virtual_network_type',
                   get_enum_type(VNET_TYPES),
                   options_list=['--virtual-network', '-v'],
                   help='The virtual network type.')
        c.argument('sku_name',
                   arg_type=get_enum_type(SKU_TYPES),
                   help='The sku of the api management instance')
        c.argument('sku_capacity',
                   type=int,
                   help='The number of deployed units of the SKU.')
        c.argument(
            'enable_managed_identity',
            arg_type=get_three_state_flag(),
            help=
            'Create a managed identity for the API Management service to access other Azure resources.'
        )

    with self.argument_context('apim update') as c:
        c.argument(
            'publisher_name',
            help=
            'The name of your organization for use in the developer portal and e-mail notifications.'
        )
        c.argument(
            'publisher_email',
            help='The e-mail address to receive all system notifications.')
        c.argument(
            'enable_client_certificate',
            arg_type=get_three_state_flag(),
            help=
            'Enforces a client certificate to be presented on each request to the gateway and also enables the ability to authenticate the certificate in the policy on the gateway.'
        )
        c.argument('virtual_network_type',
                   get_enum_type(VNET_TYPES),
                   options_list=['--virtual-network', '-v'],
                   help='The virtual network type.')
        c.argument('sku_name',
                   arg_type=get_enum_type(SKU_TYPES),
                   help='The sku of the api management instance')
        c.argument('sku_capacity',
                   type=int,
                   help='The number of deployed units of the SKU.')
        c.argument(
            'enable_managed_identity',
            arg_type=get_three_state_flag(),
            help=
            'Create a managed identity for the API Management service to access other Azure resources.'
        )

    with self.argument_context('apim backup') as c:
        c.argument('backup_name',
                   help='The name of the backup file to create.')
        c.argument(
            'storage_account_name',
            arg_group='Storage',
            help='The name of the storage account used to place the backup.')
        c.argument(
            'storage_account_key',
            arg_group='Storage',
            help=
            'The access key of the storage account used to place the backup.')
        c.argument(
            'storage_account_container',
            options_list=['--storage-account-container', '--container-name'],
            help=
            'The name of the storage account container used to place the backup.'
        )

    with self.argument_context('apim restore') as c:
        c.argument('backup_name',
                   help='The name of the backup file to restore.')
        c.argument(
            'storage_account_name',
            arg_group='Storage',
            help=
            'The name of the storage account used to retrieve the backup from.'
        )
        c.argument(
            'storage_account_key',
            arg_group='Storage',
            help=
            'The access key of the storage account used to retrieve the backup from.'
        )
        c.argument(
            'storage_account_container',
            options_list=['--storage-account-container', '--container-name'],
            help=
            'The name of the storage account container used to retrieve the backup from.'
        )

    with self.argument_context('apim api show') as c:
        c.argument('service_name',
                   options_list=['--service-name'],
                   help='The name of the API Management service instance.')
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )

    with self.argument_context('apim api list') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help='The name of the API Management service instance.')
        c.argument('filter_display_name',
                   arg_group='API',
                   help='Filter of APIs by displayName.')
        c.argument('skip', type=int, help='Number of records to skip.')
        c.argument('top', type=int, help='Number of records to return.')

    with self.argument_context('apim api create') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help='The name of the API Management service instance.')
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.',
            required=True)
        c.argument(
            'path',
            arg_group='API',
            help=
            'Required. Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance.',
            required=True)
        c.argument('display_name',
                   arg_group='API',
                   help='API name. Must be 1 to 300 characters long.',
                   required=True)
        c.argument(
            'description',
            arg_group='API',
            help='Description of the API. May include HTML formatting tags.')
        c.argument('subscription_key_header_name',
                   arg_group='API',
                   help='Specifies the subscription key header name.')
        c.argument(
            'subscription_key_query_param_name',
            arg_group='API',
            help='Specifies the subscription key query string parameter name.')
        c.argument('open_id_provider_id',
                   help='Specifies the openid in the authentication setting.')
        c.argument('bearer_token_sending_methods',
                   nargs='+',
                   help='Specifies the sending methods for bearer token.')
        c.argument('authorization_server_id',
                   help='Specifies the OAuth authorization server ID.')
        c.argument('authorization_scope',
                   help='Specifies the OAuth operations scope.')
        c.argument(
            'service_url',
            arg_group='API',
            help=
            'Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long.'
        )
        c.argument(
            'protocols',
            arg_group='API',
            arg_type=get_enum_type(API_PROTOCOLS),
            nargs='+',
            help=
            'Describes on which protocols the operations in this API can be invoked.'
        )
        c.argument('api_type',
                   arg_group='API',
                   arg_type=get_enum_type(API_TYPES),
                   help='The type of the API.')
        c.argument(
            'subscription_required',
            arg_group='API',
            arg_type=get_three_state_flag(),
            help='If true, the API requires a subscription key on requests.')
        c.argument(
            'subscription_key_required',
            help=
            'Specifies whether subscription key is required during call to this API, true - API is included into closed products only, false - API is included into open products alone, null - there is a mix of products.'
        )
        c.argument('tags', tags_type)

    with self.argument_context('apim api delete') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help='The name of the API Management service instance.')
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )
        c.argument('delete_revisions', help='Delete all revisions of the Api.')
        c.argument('if_match', help='ETag of the Entity.')

    with self.argument_context('apim api update') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help='The name of the API Management service instance.')
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.',
            required=True)
        c.argument('display_name',
                   arg_group='API',
                   help='API name. Must be 1 to 300 characters long.')
        c.argument(
            'path',
            arg_group='API',
            help=
            'Required. Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance.'
        )
        c.argument(
            'description',
            arg_group='API',
            help='Description of the API. May include HTML formatting tags.')
        c.argument('subscription_key_header_name',
                   arg_group='API',
                   help='Specifies the subscription key header name.')
        c.argument(
            'subscription_key_query_param_name',
            arg_group='API',
            help='Specifies the subscription key query string parameter name.')
        c.argument(
            'service_url',
            arg_group='API',
            help=
            'Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long.'
        )
        c.argument(
            'protocols',
            arg_group='API',
            arg_type=get_enum_type(API_PROTOCOLS),
            nargs='+',
            help=
            'Describes on which protocols the operations in this API can be invoked.'
        )
        c.argument('api_type',
                   arg_group='API',
                   arg_type=get_enum_type(API_TYPES),
                   help='The type of the API.')
        c.argument(
            'subscription_required',
            arg_group='API',
            arg_type=get_three_state_flag(),
            help='If true, the API requires a subscription key on requests.')
        c.argument('tags', tags_type)

    with self.argument_context('apim api import') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument(
            'path',
            arg_group='API',
            help=
            'Required. Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance.',
            required=True)
        c.argument('specification_format',
                   arg_type=get_enum_type(ImportFormat),
                   help='Specify the format of the imported API.')
        c.argument(
            'description',
            arg_group='API',
            help='Description of the API. May include HTML formatting tags.')
        c.argument('subscription_key_header_name',
                   arg_group='API',
                   help='Specifies the subscription key header name.')
        c.argument(
            'subscription_key_query_param_name',
            arg_group='API',
            help='Specifies the subscription key query string parameter name.')
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )
        c.argument(
            'api_revision',
            arg_group='API',
            help=
            'Describes the Revision of the Api. If no value is provided, default revision 1 is created.'
        )
        c.argument(
            'api_version',
            arg_group='API',
            help=
            'Describes the Version of the Api. If you add a version to a non-versioned API, an Original version will be automatically created and will respond on the default URL'
        )
        c.argument('api_version_set_id',
                   arg_group='API',
                   help='Describes the Version Set to be used with the API')
        c.argument(
            'service_url',
            arg_group='API',
            help=
            'Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long.'
        )
        c.argument(
            'protocols',
            arg_group='API',
            arg_type=get_enum_type(API_PROTOCOLS),
            nargs='+',
            help=
            'Describes on which protocols(one or more) the operations in this API can be invoked.'
        )
        c.argument('api_type',
                   arg_group='API',
                   arg_type=get_enum_type(API_TYPES),
                   help='The type of the API.')
        c.argument(
            'subscription_required',
            arg_group='API',
            arg_type=get_three_state_flag(),
            help='If true, the API requires a subscription key on requests.')
        c.argument('display_name',
                   arg_group='API',
                   help='Display name of this API.')
        c.argument('specification_path',
                   help='File path specified to import the API.')
        c.argument('specification_url',
                   help='Url specified to import the API.')
        c.argument('soap_api_type',
                   help='The type of API when file format is WSDL.')
        c.argument('wsdl_service_name',
                   help='Local name of WSDL Service to be imported.')
        c.argument('wsdl_endpoint_name',
                   help='Local name of WSDL Endpoint (port) to be imported.')

    with self.argument_context('apim product api list') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument(
            'product_id',
            help=
            "Product identifier. Must be unique in the current API Management service instance."
        )

    with self.argument_context('apim product api check') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument(
            'product_id',
            help=
            "Product identifier. Must be unique in the current API Management service instance."
        )
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )

    with self.argument_context('apim product api add') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument(
            'product_id',
            help=
            "Product identifier. Must be unique in the current API Management service instance."
        )
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )

    with self.argument_context('apim product api delete') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument(
            'product_id',
            help=
            "Product identifier. Must be unique in the current API Management service instance."
        )
        c.argument(
            'api_id',
            arg_group='API',
            help=
            'API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )

    with self.argument_context('apim product') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the api management service instance",
                   id_part=None)
        c.argument(
            'product_id',
            help=
            "Product identifier. Must be unique in the current API Management service instance."
        )
        c.argument('product_name', help="Product name.")
        c.argument(
            'description',
            help="Product description. May include HTML formatting tags.")
        c.argument(
            'legal_terms',
            help=
            "Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process."
        )
        c.argument(
            'subscription_required',
            options_list=['--subscription-required', '-s'],
            help=
            "Whether a product subscription is required for accessing APIs included in this product."
        )
        c.argument(
            'approval_required',
            help=
            "whether subscription approval is required. If false, new subscriptions will be approved automatically enabling developers to call the product’s APIs immediately after subscribing. If true, administrators must manually approve the subscription before the developer can any of the product’s APIs. Can be present only if subscriptionRequired property is present and has a value of false."
        )
        c.argument(
            'subscriptions_limit',
            help=
            "Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false."
        )
        c.argument(
            'state',
            arg_type=get_enum_type(ProductState),
            help=
            "whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state of Product is notPublished. Possible values include: 'notPublished', 'published'"
        )
        c.argument(
            'delete_subscriptions',
            help=
            "Delete existing subscriptions associated with the product or not."
        )
        c.argument('if_match', help='ETag of the Entity.')

    with self.argument_context('apim nv') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help='The name of the API Management service instance.')
        c.argument('named_value_id', help='Identifier of the NamedValue.')
        c.argument(
            'display_name',
            help=
            'Required. Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters.'
        )
        c.argument(
            'value',
            help=
            'Required. Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. This property will not be filled on GET operations! Use /listSecrets POST request to get the value.'
        )
        c.argument(
            'secret',
            arg_type=get_three_state_flag(),
            help=
            'Determines whether the value is a secret and should be encrypted or not. Default value is false.'
        )
        c.argument('tags', tags_type)

    with self.argument_context('apim api operation') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the API Management service instance.")
        c.argument(
            'api_id',
            help=
            'API identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )
        c.argument(
            'operation_id',
            help=
            'Operation identifier within an API. Must be unique in the current API Management service instance.'
        )
        c.argument(
            'description',
            help=
            "Description of the operation. May include HTML formatting tags.")
        c.argument('template_parameters',
                   options_list=['--template-parameters', '--params', '-p'],
                   action=TemplateParameter,
                   nargs='+',
                   help="Collection of URL template parameters.")
        c.argument(
            'method',
            help=
            "Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them."
        )
        c.argument('display_name', help="Required. Operation Name.")
        c.argument('if_match', help='ETag of the Entity.')
        c.argument(
            'url_template',
            help=
            'Relative URL template identifying the target resource for this operation. May include parameters.'
        )

    with self.argument_context('apim api release') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the API Management service instance.")
        c.argument(
            'api_id',
            help=
            'API identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )
        c.argument(
            'release_id',
            help=
            "Release identifier within an API. Must be unique in the current API Management service instance."
        )
        c.argument('api_revision', help="API revision number.")
        c.argument('notes', help="Release Notes.")
        c.argument('if_match', help='ETag of the Entity.')

    with self.argument_context('apim api revision') as c:
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the API Management service instance.")
        c.argument(
            'api_id',
            help=
            'API identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.'
        )
        c.argument('api_revision', help='Describes the Revision of the Api.')
        c.argument(
            'api_revision_description',
            options_list=['--api-revision-description', '--rev-description'],
            help='Description of the Api Revision.')

    with self.argument_context('apim api versionset') as c:
        c.argument('version_set_id',
                   help="A resource identifier for the related ApiVersionSet.")
        c.argument(
            'versioning_scheme',
            help=
            "Required. An value that determines where the API Version identifer will be located in a HTTP request. Possible values include: 'Segment', 'Query', 'Header'"
        )
        c.argument('display_name', help="Required. Name of API Version Set")
        c.argument('service_name',
                   options_list=['--service-name', '-n'],
                   help="The name of the API Management service instance.")
        c.argument('description', help="Description of API Version Set.")
        c.argument(
            'version_query_name',
            help=
            "Name of query parameter that indicates the API Version if versioningScheme is set to `query`."
        )
        c.argument(
            'version_header_name',
            help=
            "Name of HTTP header parameter that indicates the API Version if versioningScheme is set to `header`."
        )
        c.argument('if_match', help='ETag of the Entity.')