How to use the knack.arguments.CLIArgumentType function in knack

To help you get started, we’ve selected a few knack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-cli-extensions / src / imagebuilder / azext_imagebuilder / _params.py View on Github external
def load_arguments(self, _):

    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    image_template_name = CLIArgumentType(overrides=name_arg_type,
                                          help='The name of the image Template', id_part='name')

    with self.argument_context('imagebuilder create') as c:
        c.argument('resource_group', resource_group_name_type)
        c.argument('image_template_name', image_template_name)
        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('customize', id_part=None, help='Specifies the properties used to describe the customization steps of the image, like Image source etc', action=ImageBuilderAddCustomize, nargs='+')
        # c.argument('distribute', id_part=None, help='The distribution targets where the image output needs to go to.', nargs='+')
        c.argument('build_timeout_in_minutes', id_part=None, help='Maximum duration to wait while building the image template. Omit or specify 0 to use the default (4 hours).')
        c.argument('vm_size', id_part=None, help='Size of the virtual machine used to build, customize and capture images. Omit or specify empty string to use the default (Standard_D1_v2).')
        c.argument('_type', options_list=['--type'], arg_type=get_enum_type(['UserAssigned', 'None']), id_part=None, help='The type of identity used for the image template. The type \'None\' will remove any identities from the image template.')
        c.argument('user_assigned_identities', id_part=None, help='The list of user identities associated with the image template. The user identity dictionary key references will be ARM resource ids in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}\'.')
github Azure / azure-cli-extensions / src / express-route-cross-connection / azext_expressroutecrossconnection / _params.py View on Github external
def load_arguments(self, _):

    ExpressRoutePeeringType = self.get_models('ExpressRoutePeeringType')

    name_arg_type = CLIArgumentType(options_list=('--name', '-n'), metavar='NAME')
    cross_connection_name_type = CLIArgumentType(options_list=('--cross-connection-name',), metavar='NAME', help='ExpressRoute cross-connection name.', id_part='name', completer=get_resource_name_completion_list('Microsoft.Network/expressRouteCrossConnections'))
    routing_registry_values = ['ARIN', 'APNIC', 'AFRINIC', 'LACNIC', 'RIPENCC', 'RADB', 'ALTDB', 'LEVEL3']
    device_path_values = ['primary', 'secondary']

    with self.argument_context('network cross-connection') as c:
        c.argument('cross_connection_name', cross_connection_name_type, options_list=['--name', '-n'])
        c.argument('device_path', options_list='--path', arg_type=get_enum_type(device_path_values))

    with self.argument_context('network cross-connection update') as c:
        c.argument('notes', help='Service provider notes.')
        c.argument('provisioning_state', arg_type=get_enum_type(['Provisioning', 'Provisioned', 'NotProvisioned']), help='Provisioning state of the customer ExpressRoute circuit.')

    with self.argument_context('network cross-connection peering') as c:
        # Using six.integer_types so we get int for Py3 and long for Py2
        c.argument('peer_asn', help='Autonomous system number of the customer/connectivity provider.', type=six.integer_types[-1])
        c.argument('vlan_id', help='Identifier used to identify the customer.', type=int)
        c.argument('cross_connection_name', cross_connection_name_type)
github Azure / azure-cli / src / azure-cli / azure / cli / command_modules / sql / _params.py View on Github external
max_size_bytes_param_type = CLIArgumentType(
    options_list=['--max-size'],
    type=SizeWithUnitConverter('B', result_type=int),
    help='The max storage size. If no unit is specified, defaults to bytes (B).')

zone_redundant_param_type = CLIArgumentType(
    options_list=['--zone-redundant', '-z'],
    help='Specifies whether to enable zone redundancy',
    arg_type=get_three_state_flag())

managed_instance_param_type = CLIArgumentType(
    options_list=['--managed-instance', '--mi'],
    help='Name of the Azure SQL managed instance.')

kid_param_type = CLIArgumentType(
    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"')

server_key_type_param_type = CLIArgumentType(
    options_list=['--server-key-type', '-t'],
    help='The type of the server key',
    arg_type=get_enum_type(ServerKeyType))

storage_param_type = CLIArgumentType(
    options_list=['--storage'],
    type=SizeWithUnitConverter('GB', result_type=int, unit_map=dict(B=1.0 / (1024 * 1024 * 1024),
                                                                    kB=1.0 / (1024 * 1024),
                                                                    MB=1.0 / 1024,
                                                                    GB=1,
                                                                    TB=1024)),
github Azure / azure-cli-extensions / src / eventgrid / azext_eventgrid / _params.py View on Github external
options_list=['--domain-topic-name'],
    completer=get_resource_name_completion_list('Microsoft.EventGrid/domains/topic'))

system_topic_name_type = CLIArgumentType(
    help='Name of the system topic.',
    arg_type=name_type,
    options_list=['--system-topic-name'],
    completer=get_resource_name_completion_list('Microsoft.EventGrid/systemtopics'))

partner_registration_name_type = CLIArgumentType(
    help='Name of the partner registration.',
    arg_type=name_type,
    options_list=['--partner-registration-name'],
    completer=get_resource_name_completion_list('Microsoft.EventGrid/partnerregistrations'))

partner_namespace_name_type = CLIArgumentType(
    help='Name of the partner namespace.',
    arg_type=name_type,
    options_list=['--partner-namespace-name'],
    completer=get_resource_name_completion_list('Microsoft.EventGrid/partnernamespaces'))

event_channel_name_type = CLIArgumentType(
    help='Name of the event channel.',
    arg_type=name_type,
    options_list=['--event-channel-name'],
    completer=get_resource_name_completion_list('Microsoft.EventGrid/partnernamespaces/eventchannels'))

partner_topic_name_type = CLIArgumentType(
    help='Name of the partner topic.',
    arg_type=name_type,
    options_list=['--partner-topic-name'],
    completer=get_resource_name_completion_list('Microsoft.EventGrid/partnertopics'))
github Azure / azure-cli / src / azure-cli / azure / cli / command_modules / backup / _params.py View on Github external
backup_management_type_help = """Specifiy the backup management type. Define how Azure Backup manages the backup of entities within the ARM resource. For eg: AzureWorkloads refers to workloads installed within Azure VMs, AzureStorage refers to entities within Storage account. Required only if friendly name is used as Container name."""
container_name_help = """Name of the backup container. Accepts 'Name' or 'FriendlyName' from the output of az backup container list command. If 'FriendlyName' is passed then BackupManagementType is required."""
workload_type_help = """Specifiy the type of applications within the Resource which should be discovered and protected by Azure Backup. """
restore_mode_help = """Specify the restore mode."""
resolve_conflict_help = "Instruction if there's a conflict with the restored data."
resource_id_help = """ID of the Azure Resource containing items to be protected by Azure Backup service. Currently, only Azure VM resource IDs are supported."""
policy_help = """JSON encoded policy definition. Use the show command with JSON output to obtain a policy object. Modify the values using a file editor and pass the object."""
target_server_type_help = """Specify the type of the server which should be discovered."""
protectable_item_name_type_help = """Specify the resource name to be protected by Azure Backup service."""
backup_type_help = """'Full, Differential, Log, Copy-only-full' for backup Item type 'MSSQL'. 'Full, Differential' for backup item type 'SAPHANA'."""
retain_until_help = """The date until which this backed up copy will be available for retrieval, in UTC (d-m-Y). For SAPHANA and SQL workload, retain-until parameter value will be overridden by the underlying policy."""

vault_name_type = CLIArgumentType(help='Name of the Recovery services vault.', options_list=['--vault-name', '-v'], completer=get_resource_name_completion_list('Microsoft.RecoveryServices/vaults'))
container_name_type = CLIArgumentType(help=container_name_help, options_list=['--container-name', '-c'])
item_name_type = CLIArgumentType(help='Name of the backed up item.', options_list=['--item-name', '-i'])
policy_name_type = CLIArgumentType(help='Name of the backup policy.', options_list=['--policy-name', '-p'])
job_name_type = CLIArgumentType(help='Name of the job.', options_list=['--name', '-n'])
rp_name_type = CLIArgumentType(help='Name of the recovery point.', options_list=['--rp-name', '-r'])
backup_management_type = CLIArgumentType(help=backup_management_type_help, arg_type=get_enum_type(allowed_backup_management_types), options_list=['--backup-management-type'])
workload_type = CLIArgumentType(help=workload_type_help, arg_type=get_enum_type(allowed_workload_types), options_list=['--workload-type'])
restore_mode_type = CLIArgumentType(help=restore_mode_help, arg_type=get_enum_type(['OriginalLocation', 'AlternateLocation']), options_list=['--restore-mode'])
restore_mode_workload_type = CLIArgumentType(help=restore_mode_help, arg_type=get_enum_type(['AlternateWorkloadRestore', 'OriginalWorkloadRestore']), options_list=['--restore-mode'])
resolve_conflict_type = CLIArgumentType(help=resolve_conflict_help, arg_type=get_enum_type(['Overwrite', 'Skip']), options_list=['--resolve-conflict'])
resource_id_type = CLIArgumentType(help=resource_id_help, options_list=['--resource-id'])
policy_type = CLIArgumentType(help=policy_help, options_list=['--policy'], completer=FilesCompleter(), type=file_type)
protectable_item_type = CLIArgumentType(help=workload_type_help, options_list=['--protectable-item-type'], arg_type=get_enum_type(allowed_protectable_item_type))
target_server_type = CLIArgumentType(help=target_server_type_help, options_list=['--target-server-type'], arg_type=get_enum_type(allowed_protectable_item_type))
protectable_item_name_type = CLIArgumentType(help=protectable_item_name_type_help, options_list=['--protectable-item-name'])


# pylint: disable=too-many-statements
github Azure / azure-cli / src / azure-cli / azure / cli / command_modules / appconfig / _params.py View on Github external
help='Customize output fields.',
        validator=validate_query_fields,
        arg_type=get_enum_type(['key', 'value', 'label', 'content_type', 'etag', 'tags', 'locked', 'last_modified'])
    )
    feature_fields_arg_type = CLIArgumentType(
        nargs='+',
        help='Customize output fields for Feature Flags.',
        validator=validate_feature_query_fields,
        arg_type=get_enum_type(['key', 'label', 'locked', 'last_modified', 'state', 'description', 'conditions'])
    )
    filter_parameters_arg_type = CLIArgumentType(
        validator=validate_filter_parameters,
        help="Space-separated filter parameters in 'name[=value]' format.",
        nargs='*'
    )
    datatime_filter_arg_type = CLIArgumentType(
        validator=validate_datetime,
        help='Format: "YYYY-MM-DDThh:mm:ssZ". If no time zone specified, use UTC by default.'
    )
    top_arg_type = CLIArgumentType(
        options_list=['--top', '-t'],
        type=int,
        help='Maximum number of items to return. Must be a positive integer. Default to 100.'
    )

    with self.argument_context('appconfig') as c:
        c.argument('resource_group_name', arg_type=resource_group_name_type)
        c.argument('name', options_list=['--name', '-n'], id_part='None', help='Name of the App Configuration. You can configure the default name using `az configure --defaults app_configuration_store=`', configured_default='app_configuration_store')
        c.argument('connection_string', validator=validate_connection_string, configured_default='appconfig_connection_string',
                   help="Combination of access key and endpoint of App Configuration. Can be found using 'az appconfig credential list'. Users can preset it using `az configure --defaults appconfig_connection_string=` or environment variable with the name AZURE_APPCONFIG_CONNECTION_STRING.")
        c.argument('yes', options_list=['--yes', '-y'], help='Do not prompt for confirmation.')
        c.argument('datetime', arg_type=datatime_filter_arg_type)
github Azure / azure-cli / src / azure-cli / azure / cli / command_modules / vm / _params.py View on Github external
def load_arguments(self, _):
    # Model imports
    StorageAccountTypes = self.get_models('StorageAccountTypes')
    DiskStorageAccountTypes = self.get_models('DiskStorageAccountTypes,', operation_group='disks')
    SnapshotStorageAccountTypes = self.get_models('SnapshotStorageAccountTypes', operation_group='snapshots')
    UpgradeMode, CachingTypes, OperatingSystemTypes = self.get_models('UpgradeMode', 'CachingTypes', 'OperatingSystemTypes')
    HyperVGenerationTypes, HyperVGeneration = self.get_models('HyperVGenerationTypes', 'HyperVGeneration')
    DedicatedHostLicenseTypes = self.get_models('DedicatedHostLicenseTypes')

    # 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=`",
                                       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=`",
                                     id_part='name')

    extension_instance_name_type = CLIArgumentType(help="Name of extension instance, which can be customized. Default: name of the extension.")
    image_template_name_type = CLIArgumentType(overrides=name_arg_type, id_part='name')
    disk_encryption_set_name = CLIArgumentType(overrides=name_arg_type, help='Name of disk encryption set.', id_part='name')

    # StorageAccountTypes renamed to DiskStorageAccountTypes in 2018_06_01 of azure-mgmt-compute
github Azure / azure-cli-extensions / src / peering / azext_peering / generated / _params.py View on Github external
with self.argument_context('peering peering show') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('peering_name', help='The name of the peering.')

    with self.argument_context('peering peering create') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('peering_name', help='The name of the peering.')
        c.argument('sku', action=AddPeeringsSku, nargs='+', help='The SKU that defines the tier and kind of the peering'
                   '. Expect value: KEY1=VALUE1 KEY2=VALUE2 ... , available KEYs are: name, tier, family, size.')
        c.argument('kind', arg_type=get_enum_type(['Direct', 'Exchange']), help='The kind of the peering.')
        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('direct', arg_type=CLIArgumentType(options_list=['--direct'], help='The properties that define a dir'
                   'ect peering. Expected value: json-string/@json-file.'))
        c.argument('exchange', arg_type=CLIArgumentType(options_list=['--exchange'], help='The properties that define a'
                   'n exchange peering. Expected value: json-string/@json-file.'))
        c.argument('peering_location', help='The location of the peering.')

    with self.argument_context('peering peering update') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('peering_name', help='The name of the peering.')
        c.argument('tags', tags_type)

    with self.argument_context('peering peering delete') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('peering_name', help='The name of the peering.')

    with self.argument_context('peering received-route list') as c:
        c.argument('resource_group_name', resource_group_name_type)
        c.argument('peering_name', help='The name of the peering.')
        c.argument('prefix', help='The optional prefix that can be used to filter the routes.')
github Azure / azure-cli / src / azure-cli / azure / cli / command_modules / advisor / _params.py View on Github external
def load_arguments(self, _):
    ids_arg_type = CLIArgumentType(nargs='+', options_list=['--ids'],
                                   help='One or more resource IDs (space-delimited). If provided, no other '
                                        '"Resource Id" arguments should be specified.')

    name_arg_type = CLIArgumentType(options_list=['--name', '-n'],
                                    help='The name of the recommendation as output by the list command.',
                                    completer=get_resource_name_completion_list('Microsoft.Advisor/recommendations'))

    with self.argument_context('advisor recommendation list') as c:
        c.argument('ids', ids_arg_type, validator=validate_ids_or_resource_group)
        c.argument('category', options_list=['--category', '-c'], help='Name of recommendation category.',
                   arg_type=get_enum_type(['Cost', 'HighAvailability', 'Performance', 'Security']))
        c.argument('refresh', options_list=['--refresh', '-r'], action='store_true',
                   help='Generate new recommendations.')

    with self.argument_context('advisor recommendation disable') as c:
        c.argument('ids', ids_arg_type, arg_group="Resource Id", validator=validate_ids_or_names)
github Azure / azure-cli-extensions / src / eventgrid / azext_eventgrid / _params.py View on Github external
get_location_type,
    get_enum_type,
    tags_type,
    name_type
)

from .advanced_filter import EventSubscriptionAddFilter
from .event_channel_filter import EventChannelAddFilter
from .inbound_ip_rules import AddInboundIpRule

included_event_types_type = CLIArgumentType(
    help="A space-separated list of event types. Example: Microsoft.Storage.BlobCreated Microsoft.Storage.BlobDeleted. To subscribe to all default event types, do not specify any value for this argument.",
    nargs='+'
)

labels_type = CLIArgumentType(
    help="A space-separated list of labels to associate with this event subscription.",
    nargs='+'
)

authorized_subscription_ids_type = CLIArgumentType(
    help="A space-separated list of Azure subscription Ids that are authorized to create a partner namespace associated with this partner registration. This is an optional property. Creating partner namespaces is always permitted under the same Azure subscription as the one used for creating the partner registration.",
    nargs='+'
)

input_schema_type = CLIArgumentType(
    help="Schema in which incoming events will be published to this topic/domain. If you specify customeventschema as the value for this parameter, you must also provide values for at least one of --input_mapping_default_values / --input_mapping_fields.",
    arg_type=get_enum_type(['eventgridschema', 'customeventschema', 'cloudeventschemav1_0'], default='eventgridschema')
)

public_network_access_type = CLIArgumentType(
    help="This determines if traffic is allowed over public network. By default it is enabled. You can further restrict to specific IPs by configuring.",