Пример #1
0
def register_common_storage_account_options(context):
    context.reg_arg('https_only', help='Allows https traffic only to storage service.', **three_state_flag())
    context.reg_arg('sku', help='The storage account SKU.', **model_choice_list(ResourceType.MGMT_STORAGE, 'SkuName'))
    context.reg_arg('access_tier', help='The access tier used for billing StandardBlob accounts. Cannot be set for '
                                        'StandardLRS, StandardGRS, StandardRAGRS, or PremiumLRS account types. It is '
                                        'required for StandardBlob accounts during creation',
                    **model_choice_list(ResourceType.MGMT_STORAGE, 'AccessTier'))

    # after API 2016-12-01
    if supported_api_version(resource_type=ResourceType.MGMT_STORAGE, min_api='2016-12-01'):
        encryption_services_model = get_sdk(ResourceType.MGMT_STORAGE, 'models#EncryptionServices')
        if encryption_services_model:

            encryption_choices = []
            for attribute in encryption_services_model._attribute_map.keys():  # pylint: disable=protected-access
                if not encryption_services_model._validation.get(attribute, {}).get('readonly'):  # pylint: disable=protected-access
                    # skip readonly attributes, which are not for input
                    encryption_choices.append(attribute)

            context.reg_arg('encryption_services', nargs='+', help='Specifies which service(s) to encrypt.',
                            validator=validate_encryption_services, **enum_choice_list(encryption_choices))

    # after API 2017-06-01
    if supported_api_version(resource_type=ResourceType.MGMT_STORAGE, min_api='2017-06-01'):
        context.reg_arg('assign_identity', action='store_true',
                        help='Generate and assign a new Storage Account Identity for this storage account for use with '
                             'key management services like Azure KeyVault.')

        # the options of encryption key sources are hardcoded since there isn't a enum represents them in the SDK.
        context.reg_arg('encryption_key_source', help='The encryption keySource (provider). Default: Microsoft.Storage',
                        validator=validate_encryption_source,
                        **enum_choice_list(['Microsoft.Storage', 'Microsoft.Keyvault']))
Пример #2
0
    def test_case_insensitive_enum_choices(self):
        from enum import Enum

        class TestEnum(Enum):  # pylint: disable=too-few-public-methods

            opt1 = "ALL_CAPS"
            opt2 = "camelCase"
            opt3 = "snake_case"

        def test_handler():
            pass

        command = CliCommand('test command', test_handler)
        command.add_argument('opt', '--opt', required=True, **enum_choice_list(TestEnum))
        cmd_table = {'test command': command}

        parser = AzCliCommandParser()
        parser.load_command_table(cmd_table)

        args = parser.parse_args('test command --opt alL_cAps'.split())
        self.assertEqual(args.opt, 'ALL_CAPS')

        args = parser.parse_args('test command --opt CAMELCASE'.split())
        self.assertEqual(args.opt, 'camelCase')

        args = parser.parse_args('test command --opt sNake_CASE'.split())
        self.assertEqual(args.opt, 'snake_case')
Пример #3
0
    def test_case_insensitive_enum_choices(self):
        from enum import Enum

        class TestEnum(Enum):  # pylint: disable=too-few-public-methods

            opt1 = "ALL_CAPS"
            opt2 = "camelCase"
            opt3 = "snake_case"

        def test_handler():
            pass

        command = CliCommand('test command', test_handler)
        command.add_argument('opt',
                             '--opt',
                             required=True,
                             **enum_choice_list(TestEnum))
        cmd_table = {'test command': command}

        parser = AzCliCommandParser()
        parser.load_command_table(cmd_table)

        args = parser.parse_args('test command --opt alL_cAps'.split())
        self.assertEqual(args.opt, 'ALL_CAPS')

        args = parser.parse_args('test command --opt CAMELCASE'.split())
        self.assertEqual(args.opt, 'camelCase')

        args = parser.parse_args('test command --opt sNake_CASE'.split())
        self.assertEqual(args.opt, 'snake_case')
Пример #4
0
name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')
multi_ids_type = CliArgumentType(nargs='+')
existing_vm_name = CliArgumentType(overrides=name_arg_type,
                                   help='The name of the Virtual Machine',
                                   completer=get_resource_name_completion_list(
                                       'Microsoft.Compute/virtualMachines'),
                                   id_part='name')
vmss_name_type = CliArgumentType(
    name_arg_type,
    completer=get_resource_name_completion_list(
        'Microsoft.Compute/virtualMachineScaleSets'),
    help='Scale set name.',
    id_part='name')
disk_sku = CliArgumentType(required=False,
                           help='underlying storage sku',
                           **enum_choice_list(['Premium_LRS', 'Standard_LRS']))

# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
register_cli_argument('vm', 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

for item in ['show', 'list']:
    register_cli_argument(
        'vm {}'.format(item),
        'show_details',
        action='store_true',
        options_list=('--show-details', '-d'),
        help=
Пример #5
0
register_cli_argument('ad app', 'application_object_id', options_list=('--object-id',))
register_cli_argument('ad app', 'display_name', help=' the display name of the application')
register_cli_argument('ad app', 'homepage', help='the url where users can sign in and use your app.')
register_cli_argument('ad app', 'identifier', options_list=('--id',), help='identifier uri, application id, or object id')
register_cli_argument('ad app', 'identifier_uris', nargs='+', help='space separated unique URIs that Azure AD can use for this app.')
register_cli_argument('ad app', '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.')
register_cli_argument('ad app', 'start_date', help='the start date after which password or key would be valid. Default value is current time')
register_cli_argument('ad app', 'end_date', help='the end date till which password or key is valid. Default value is one year after current time')
register_cli_argument('ad app', 'available_to_other_tenants', action='store_true', help='the application can be used from any Azure AD tenants')
register_cli_argument('ad app', '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
register_cli_argument('ad app', 'key_type', default='AsymmetricX509Cert',
                      help='the type of the key credentials associated with the application',
                      **enum_choice_list(['AsymmetricX509Cert', 'Password', 'Symmetric']))
register_cli_argument('ad app', 'key_usage', default='Verify',
                      help='the usage of the key credentials associated with the application.',
                      **enum_choice_list(['Sign', 'Verify']))

name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

register_cli_argument('ad sp', 'identifier', options_list=('--id',), help='service principal name, or object id')
register_cli_argument('ad sp create', 'identifier', options_list=('--id',), help='identifier uri, application id, or object id of the associated application')
register_cli_argument('ad sp create-for-rbac', 'name', name_arg_type)
register_cli_argument('ad sp create-for-rbac', 'years', type=int)
register_cli_argument('ad sp create-for-rbac', 'scopes', nargs='+')
register_cli_argument('ad sp create-for-rbac', 'role', completer=get_role_definition_name_completion_list)
register_cli_argument('ad sp create-for-rbac', 'expanded_view', action='store_true', help='Once created, display more information like subscription and cloud environments')
register_cli_argument('ad sp reset-credentials', 'name', name_arg_type)
register_cli_argument('ad sp reset-credentials', 'years', type=int)
Пример #6
0
# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
register_cli_argument('vm', 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

for item in ['show', 'list']:
    register_cli_argument('vm {}'.format(item), 'show_details', action='store_true', options_list=('--show-details', '-d'), help='show public ip address, FQDN, and power states. command will run slow')

register_cli_argument('vm disk', 'vm_name', arg_type=existing_vm_name, options_list=('--vm-name',))
register_cli_argument('vm disk', 'disk_name', options_list=('--name', '-n'), help='The data disk name. If missing, will retrieve from vhd uri')
register_cli_argument('vm disk', 'disk_size', help='Size of disk (GiB)', default=1023, type=int)
register_cli_argument('vm disk', 'lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virutal Machine size.')
register_cli_argument('vm disk', 'vhd', type=VirtualHardDisk, help='virtual hard disk\'s uri. For example:https://mystorage.blob.core.windows.net/vhds/d1.vhd')
register_cli_argument('vm disk', 'caching', help='Host caching policy', default=CachingTypes.none.value, **enum_choice_list(CachingTypes))

for item in ['attach-existing', 'attach-new', 'detach']:
    register_cli_argument('vm disk {}'.format(item), 'vm_name', arg_type=existing_vm_name, options_list=('--vm-name',), id_part=None)

register_cli_argument('vm availability-set', 'availability_set_name', name_arg_type, completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')

register_cli_argument('vm access', 'username', options_list=('--username', '-u'), help='The user name')
register_cli_argument('vm access', 'password', options_list=('--password', '-p'), help='The user password')

register_cli_argument('acs', 'name', arg_type=name_arg_type)
register_cli_argument('acs', 'orchestrator_type', **enum_choice_list(ContainerServiceOchestratorTypes))
# some admin names are prohibited in acs, such as root, admin, etc. Because we have no control on the orchestrators, so default to a safe name.
register_cli_argument('acs', 'admin_username', options_list=('--admin-username',), default='azureuser', required=False)
register_cli_argument('acs', 'dns_name_prefix', options_list=('--dns-prefix', '-d'))
register_extra_cli_argument('acs create', 'generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing')
Пример #7
0
    # Service tier advisors and transparent data encryption are not included in the first batch
    # of GA commands.
    c.ignore('expand')


with ParametersContext(command='sql db list') as c:
    c.argument('elastic_pool_name',
               help='If specified, lists only the databases in this elastic pool')


with ParametersContext(command='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='+',
               **enum_choice_list(DatabaseCapabilitiesAdditionalDetails))

    search_arg_group = 'Search'

    # We could used **enum_choice_list 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 ParametersContext(command='sql db update') as c:
Пример #8
0
    # Service tier advisors and transparent data encryption are not included in the first batch
    # of GA commands.
    c.ignore('expand')


with ParametersContext(command='sql db list') as c:
    c.argument('elastic_pool_name',
               help='If specified, lists only the databases in this elastic pool')


with ParametersContext(command='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='+',
               **enum_choice_list(DatabaseCapabilitiesAdditionalDetails))

    search_arg_group = 'Search'

    # We could used **enum_choice_list 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 ParametersContext(command='sql db update') as c:
Пример #9
0
register_cli_argument('sf', 'certificate_subject_name', options_list=('--certificate-subject-name'),
                      help='The subject name of the certificate to be created.')
register_cli_argument('sf', 'vault_resource_group_name', options_list=('--vault-resource-group'),
                      help='Key vault resource group name,if not given it will be cluster resource group name')
register_cli_argument('sf', 'vault_name', options_list=('--vault-name'),
                      help='Azure key vault name, it not given it will be the cluster resource group name')
register_cli_argument('sf', 'cluster_size', options_list=('--cluster-size', '-s'),
                      help='The number of nodes in the cluster. Default are 5 nodes')
register_cli_argument('sf', 'vm_sku', options_list=(
    '--vm-sku'), help='The Vm Sku')
register_cli_argument('sf', 'vm_user_name', options_list=(
    '--vm-user-name'), help='The user name for logging to Vm. Default will be adminuser')
register_cli_argument('sf', 'vm_os', default='WindowsServer2016Datacenter', options_list=('--vm-os', '--os'),
                      help='The Operating System of the VMs that make up the cluster.',
                      **enum_choice_list(['WindowsServer2012R2Datacenter',
                                          'WindowsServer2016Datacenter',
                                          'WindowsServer2016DatacenterwithContainers',
                                          'UbuntuServer1604']))

register_cli_argument('sf client certificate', 'certificate_common_name',
                      help='client certificate common name.')
register_cli_argument('sf client certificate', 'admin_client_thumbprints', nargs='+',
                      help='Space separated list of client certificate thumbprint that only has admin permission, ')
register_cli_argument('sf client certificate', 'certificate_issuer_thumbprint',
                      help='client certificate issuer thumbprint.')

register_cli_argument('sf cluster certificate', 'thumbprint',
                      help='The cluster certificate thumbprint to be removed')

register_cli_argument('sf cluster client-certificate', 'is_admin',
                      help='Client authentication type.')
register_cli_argument('sf cluster client-certificate', 'certificate_issuer_thumbprint',
Пример #10
0
        rg = parsed_args.resource_group_name
        webapp = parsed_args.webapp
        slot = getattr(parsed_args, 'slot', None)
        result = _generic_site_operation(rg, webapp,
                                         'get_site_host_name_bindings', slot)
        #workaround an api defect, that 'name' is '<webapp>/<hostname>'
        return [r.name.split('/', 1)[1] for r in result]

#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), etc',
    **enum_choice_list([
        'F1', 'FREE', 'D1', 'SHARED', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1',
        'P2', 'P3'
    ]))

register_cli_argument('appservice',
                      'resource_group_name',
                      arg_type=resource_group_name_type)
register_cli_argument('appservice', 'location', arg_type=location_type)

register_cli_argument(
    'appservice plan',
    'name',
    arg_type=name_arg_type,
    help='The name of the app service plan',
    completer=get_resource_name_completion_list('Microsoft.Web/serverFarms'),
    id_part='name')
register_cli_argument('appservice plan create',
Пример #11
0
register_cli_argument('policy definition', 'policy_definition_name', arg_type=existing_policy_definition_name_type)
register_cli_argument('policy definition create', 'name', options_list=('--name', '-n'), help='name of the new policy definition')
register_cli_argument('policy definition', 'rules', help='JSON formatted string or a path to a file with such content')
register_cli_argument('policy definition', 'display_name', help='display name of policy definition')
register_cli_argument('policy definition', 'description', help='description of policy definition')
register_cli_argument('policy assignment', 'name', options_list=('--name', '-n'), completer=get_policy_assignment_completion_list, help='name of the assignment')
register_cli_argument('policy assignment create', 'name', options_list=('--name', '-n'), help='name of the new assignment')
register_cli_argument('policy assignment', 'scope', help='scope at which this policy assignment 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')
register_cli_argument('policy assignment', 'disable_scope_strict_match', action='store_true', help='include assignment either inhertied from parent scope or at child scope')
register_cli_argument('policy assignment', 'display_name', help='display name of the assignment')
register_cli_argument('policy assignment', 'policy', help='policy name or fully qualified id', completer=get_policy_completion_list)

register_cli_argument('group', 'tag', tag_type)
register_cli_argument('group', 'tags', tags_type)
register_cli_argument('group', 'resource_group_name', resource_group_name_type, options_list=('--name', '-n'))
register_cli_argument('group deployment', 'resource_group_name', arg_type=resource_group_name_type, completer=get_resource_group_completion_list)
register_cli_argument('group deployment', 'deployment_name', options_list=('--name', '-n'), required=True, help='The deployment name.')
register_cli_argument('group deployment', 'parameters', completer=FilesCompleter(), help="provide deployment parameter values, either json string, or use '@<file path>' to load from a file")
register_cli_argument('group deployment', 'template_file', completer=FilesCompleter(), help="a template file path in the file system")
register_cli_argument('group deployment', 'template_uri', completer=FilesCompleter(), help='a uri to a remote template file')
register_cli_argument('group deployment', 'mode', help='Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)', **enum_choice_list(DeploymentMode))
register_cli_argument('group deployment create', 'deployment_name', options_list=('--name', '-n'), required=False,
                      validator=validate_deployment_name, help='The deployment name. Default to template file base name')
register_cli_argument('group deployment operation show', 'operation_ids', nargs='+', help='A list of operation ids to show')
register_cli_argument('group export', 'include_comments', action='store_true')
register_cli_argument('group export', 'include_parameter_default_value', action='store_true')
register_cli_argument('group create', 'resource_group_name', completer=None)

register_cli_argument('tag', 'tag_name', options_list=('--name', '-n'))
register_cli_argument('tag', 'tag_value', options_list=('--value',))
Пример #12
0
    def __init__(self, value):
        super(ScheduleEntryList, self).__init__()
        import json
        if value[0] in ("'", '"') and value[-1] == value[0]:
            # Remove leading and trailing quotes for dos/cmd.exe users
            value = value[1:-1]
        dictval = json.loads(value)
        self.extend([ScheduleEntry(
            row['dayOfWeek'],
            int(row['startHourUtc']),
            row.get('maintenanceWindow', None))
                     for row in dictval])

register_cli_argument('redis', 'name', arg_type=name_type, help='Name of the redis cache.', completer=get_resource_name_completion_list('Microsoft.Cache/redis'), id_part='name')
register_cli_argument('redis', 'redis_configuration', type=JsonString)
register_cli_argument('redis', 'reboot_type', **enum_choice_list(RebootType))
register_cli_argument('redis', 'key_type', **enum_choice_list(RedisKeyType))
register_cli_argument('redis', 'shard_id', type=int)
register_cli_argument('redis import-method', 'files', nargs='+')

register_cli_argument('redis patch-schedule set', 'schedule_entries', type=ScheduleEntryList)

register_cli_argument('redis create', 'name', arg_type=name_type, completer=None)
register_cli_argument('redis create', 'sku_name', **enum_choice_list(SkuName))
register_cli_argument('redis create', 'sku_family', **enum_choice_list(SkuFamily))
register_cli_argument('redis create', 'sku_capacity', choices=[str(n) for n in range(0, 7)])
register_cli_argument('redis create', 'enable_non_ssl_port', action='store_true')
register_cli_argument('redis create', 'tenant_settings', type=JsonString)
register_cli_argument('redis create', 'shard_count', type=int)
register_cli_argument('redis create', 'subnet_id') # TODO: Create generic id completer similar to name
Пример #13
0
                      **three_state_flag())
register_cli_argument('keyvault', 'enabled_for_disk_encryption',
                      help='Allow Disk Encryption to retrieve secrets from the vault and unwrap '
                           'keys.',
                      **three_state_flag())
register_cli_argument('keyvault', 'enabled_for_template_deployment',
                      help='Allow Resource Manager to retrieve secrets from the vault.',
                      **three_state_flag())
register_cli_argument('keyvault', 'enable_soft_delete',
                      help='Enable vault deletion recovery for the vault, and all contained entities',
                      **three_state_flag())

register_cli_argument('keyvault create', 'resource_group_name', resource_group_name_type,
                      required=True, completer=None, validator=None)
register_cli_argument('keyvault create', 'vault_name', completer=None)
register_cli_argument('keyvault create', 'sku', **enum_choice_list(SkuName))
register_cli_argument('keyvault create', 'no_self_perms',
                      help="Don't add permissions for the current user/service principal in the "
                           "new vault",
                      **three_state_flag())
register_cli_argument('keyvault create', 'location',
                      validator=get_default_location_from_resource_group)

register_cli_argument('keyvault list', 'resource_group_name', resource_group_name_type,
                      validator=None)

register_cli_argument('keyvault delete-policy', 'object_id', validator=validate_principal)
register_cli_argument('keyvault set-policy', 'key_permissions', metavar='PERM', nargs='*',
                      help='Space separated list of key permissions to assign.', arg_group='Permission',
                      validator=validate_policy_permissions, **enum_choice_list(KeyPermissions))
register_cli_argument('keyvault set-policy', 'secret_permissions', metavar='PERM', nargs='*',
Пример #14
0

def environment_variables_format(value):
    """Space separated values in 'key=value' format."""
    try:
        env_name, env_value = value.split('=', 1)
    except ValueError:
        message = ("Incorrectly formatted environment settings. "
                   "Argument values should be in the format a=b c=d")
        raise CLIError(message)
    return {'name': env_name, 'value': env_value}


register_cli_argument('container', 'resource_group_name', resource_group_name_type)
register_cli_argument('container', 'name', options_list=('--name', '-n'), help="The name of the container group", id_part='name')
register_cli_argument('container', 'location', location_type)

register_cli_argument('container create', 'location', location_type, validator=get_default_location_from_resource_group)
register_cli_argument('container create', 'image', help='The container image name')
register_cli_argument('container create', 'cpu', type=int, help='The required number of CPU cores of the containers')
register_cli_argument('container create', 'memory', type=float, help='The required memory of the containers in GB')
register_cli_argument('container create', 'os_type', help='The OS type of the containers', **enum_choice_list(OS_TYPES))
register_cli_argument('container create', 'ip_address', help='The IP address type of the container group', **enum_choice_list(IP_ADDRESS_TYPES))
register_cli_argument('container create', 'command_line', help='The command line to run when the container is started, e.g. \'/bin/bash -c myscript.sh\'')
register_cli_argument('container create', 'environment_variables', nargs='+', options_list=('--environment-variables', '-e'), type=environment_variables_format, help='A list of environment variable for the container. Space separated values in \'key=value\' format.')
register_cli_argument('container create', 'registry_login_server', arg_group='Image Registry', help='The container image registry login server')
register_cli_argument('container create', 'registry_username', arg_group='Image Registry', help='The username to log in container image registry server')
register_cli_argument('container create', 'registry_password', arg_group='Image Registry', help='The password to log in container image registry server')

register_cli_argument('container logs', 'container_name', help='The container name to tail the logs')
Пример #15
0
            deep_created_origin.http_port = int(values[1])
        if len(values) > 2:
            deep_created_origin.https_port = int(values[2])
        return deep_created_origin


name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

register_cli_argument('cdn', 'name', name_arg_type, id_part='name')
register_cli_argument('cdn', 'tags', tags_type)

# Profile #

register_cli_argument('cdn profile create',
                      'sku',
                      **enum_choice_list([item.value for item in list(SkuName)]))
register_cli_argument('cdn profile create', 'location',
                      validator=get_default_location_from_resource_group)
profile_name_help = 'Name of the CDN profile which is unique within the resource group.'
register_cli_argument('cdn profile', 'profile_name', name_arg_type, id_part='name',
                      help=profile_name_help)
register_cli_argument('cdn profile create', 'name', name_arg_type, id_part='name',
                      help=profile_name_help)
# Endpoint #

register_cli_argument('cdn endpoint', 'endpoint_name', name_arg_type, id_part='name',
                      help='Name of the CDN endpoint.')
register_cli_argument('cdn endpoint create', 'name', name_arg_type, id_part='name',
                      help='Name of the CDN endpoint.')
cdn_endpoint = 'cdn endpoint'
register_cli_argument(cdn_endpoint, 'location',
Пример #16
0
existing_vm_name = CliArgumentType(overrides=name_arg_type, help='The name of the virtual machine', completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines'), id_part='name')
vmss_name_type = CliArgumentType(name_arg_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachineScaleSets'), help='Scale set name.', id_part='name')

# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
register_cli_argument('vm', 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

register_cli_argument('vm disk', 'vm_name', arg_type=existing_vm_name, options_list=('--vm-name',))
register_cli_argument('vm disk', 'disk_name', options_list=('--name', '-n'), help='The data disk name. If missing, will retrieve from vhd uri')
register_cli_argument('vm disk', 'disk_size', help='Size of disk (GiB)', default=1023, type=int)
register_cli_argument('vm disk', 'lun', type=int, help='0-based logical unit number (LUN). Max value depends on the Virutal Machine size.')
register_cli_argument('vm disk', 'vhd', type=VirtualHardDisk, help='virtual hard disk\'s uri. For example:https://mystorage.blob.core.windows.net/vhds/d1.vhd')
register_cli_argument('vm disk', 'caching', help='Host caching policy', default=CachingTypes.none.value, **enum_choice_list(CachingTypes))

for item in ['attach-existing', 'attach-new', 'detach']:
    register_cli_argument('vm disk {}'.format(item), 'vm_name', arg_type=existing_vm_name, options_list=('--vm-name',), id_part=None)

register_cli_argument('vm availability-set', 'availability_set_name', name_arg_type, completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')

register_cli_argument('vm access', 'username', options_list=('--username', '-u'), help='The user name')
register_cli_argument('vm access', 'password', options_list=('--password', '-p'), help='The user password')

register_cli_argument('vm container', 'orchestrator_type', **enum_choice_list(ContainerServiceOchestratorTypes))
register_cli_argument('vm container', 'admin_username', admin_username_type)
register_cli_argument('vm container', 'ssh_key_value', required=False, help='SSH key file value or key file path.', default=os.path.join(os.path.expanduser('~'), '.ssh', 'id_rsa.pub'), completer=FilesCompleter())
register_cli_argument('vm container', 'container_service_name', options_list=('--name', '-n'), help='The name of the container service', completer=get_resource_name_completion_list('Microsoft.ContainerService/ContainerServices'))
register_cli_argument('vm container create', 'agent_vm_size', completer=get_vm_size_completion_list)
Пример #17
0
register_cli_argument('storage', 'retry_wait', options_list=('--retry-interval',))
register_cli_argument('storage', 'progress_callback', ignore_type)
register_cli_argument('storage', 'metadata', nargs='+', help='Metadata in space-separated key=value pairs. This overwrites any existing metadata.', validator=validate_metadata)
register_cli_argument('storage', 'timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

register_cli_argument('storage', 'if_modified_since', help='Alter only if modified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')', type=get_datetime_type(False), arg_group='Pre-condition')
register_cli_argument('storage', 'if_unmodified_since', help='Alter only if unmodified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')', type=get_datetime_type(False), arg_group='Pre-condition')
register_cli_argument('storage', 'if_match', arg_group='Pre-condition')
register_cli_argument('storage', 'if_none_match', arg_group='Pre-condition')

register_cli_argument('storage', 'container_name', container_name_type)
for item in ['check-name', 'delete', 'list', 'show', 'show-usage', 'update', 'keys']:
    register_cli_argument('storage account {}'.format(item), 'account_name', account_name_type, options_list=('--name', '-n'))

register_cli_argument('storage account show-connection-string', 'account_name', account_name_type, options_list=('--name', '-n'))
register_cli_argument('storage account show-connection-string', 'protocol', help='The default endpoint protocol.', **enum_choice_list(['http', 'https']))
register_cli_argument('storage account show-connection-string', 'key_name', options_list=('--key',), help='The key to use.', **enum_choice_list(list(storage_account_key_options.keys())))
for item in ['blob', 'file', 'queue', 'table']:
    register_cli_argument('storage account show-connection-string', '{}_endpoint'.format(item), help='Custom endpoint for {}s.'.format(item))


def register_common_storage_account_options(context):
    context.reg_arg('https_only', help='Allows https traffic only to storage service.', **three_state_flag())
    context.reg_arg('sku', help='The storage account SKU.', **model_choice_list(ResourceType.MGMT_STORAGE, 'SkuName'))
    context.reg_arg('access_tier', help='The access tier used for billing StandardBlob accounts. Cannot be set for '
                                        'StandardLRS, StandardGRS, StandardRAGRS, or PremiumLRS account types. It is '
                                        'required for StandardBlob accounts during creation',
                    **model_choice_list(ResourceType.MGMT_STORAGE, 'AccessTier'))

    # after API 2016-12-01
    if supported_api_version(resource_type=ResourceType.MGMT_STORAGE, min_api='2016-12-01'):
Пример #18
0
        webapp = parsed_args.webapp
        slot = getattr(parsed_args, 'slot', None)
        result = _generic_site_operation(rg, webapp,
                                         'get_site_host_name_bindings', slot)
        # workaround an api defect, that 'name' is '<webapp>/<hostname>'
        return [r.name.split('/', 1)[1] for r in result]


# 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',
    **enum_choice_list([
        '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
register_cli_argument('webapp', 'app_instance', ignore_type)
register_cli_argument('functionapp', 'app_instance', ignore_type)
Пример #19
0

# 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')
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(required=False, help='underlying storage sku', **enum_choice_list(['Premium_LRS', 'Standard_LRS']))

# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
for scope in ['vm', 'disk', 'snapshot', 'image']:
    register_cli_argument(scope, 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

with VersionConstraint(ResourceType.MGMT_COMPUTE, min_api='2017-03-30') as c:
    c.register_cli_argument('vm', 'zone', zone_type)
    c.register_cli_argument('disk', 'zone', zone_type, options_list=['--zone'])  # TODO: --size-gb currently has claimed -z. We can do a breaking change later if we want to.
    c.register_cli_argument('vmss', 'zones', zones_type)

for item in ['show', 'list']:
Пример #20
0
        webapp = parsed_args.webapp
        slot = getattr(parsed_args, 'slot', None)
        result = _generic_site_operation(rg, webapp,
                                         'get_site_host_name_bindings', slot)
        # workaround an api defect, that 'name' is '<webapp>/<hostname>'
        return [r.name.split('/', 1)[1] for r in result]


# 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',
    **enum_choice_list([
        '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
register_cli_argument('webapp', 'app_instance', ignore_type)
register_cli_argument('functionapp', 'app_instance', ignore_type)
Пример #21
0
register_cli_argument('storage', 'progress_callback', ignore_type)
register_cli_argument('storage', 'metadata', nargs='+', help='Metadata in space-separated key=value pairs. This overwrites any existing metadata.', validator=validate_metadata)
register_cli_argument('storage', 'timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

register_cli_argument('storage', 'if_modified_since', help='Alter only if modified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')', type=datetime_type, arg_group='Pre-condition')
register_cli_argument('storage', 'if_unmodified_since', help='Alter only if unmodified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')', type=datetime_type, arg_group='Pre-condition')
register_cli_argument('storage', 'if_match', arg_group='Pre-condition')
register_cli_argument('storage', 'if_none_match', arg_group='Pre-condition')

register_cli_argument('storage', 'container_name', container_name_type)

for item in ['check-name', 'delete', 'list', 'show', 'show-usage', 'update', 'keys']:
    register_cli_argument('storage account {}'.format(item), 'account_name', account_name_type, options_list=('--name', '-n'))

register_cli_argument('storage account show-connection-string', 'account_name', account_name_type, options_list=('--name', '-n'))
register_cli_argument('storage account show-connection-string', 'protocol', help='The default endpoint protocol.', **enum_choice_list(['http', 'https']))
register_cli_argument('storage account show-connection-string', 'key_name', options_list=('--key',), help='The key to use.', **enum_choice_list(list(storage_account_key_options.keys())))
for item in ['blob', 'file', 'queue', 'table']:
    register_cli_argument('storage account show-connection-string', '{}_endpoint'.format(item), help='Custom endpoint for {}s.'.format(item))

register_cli_argument('storage account create', 'account_name', account_name_type, options_list=('--name', '-n'), completer=None)

register_cli_argument('storage account create', 'kind', help='Indicates the type of storage account.', **enum_choice_list(Kind))
register_cli_argument('storage account create', 'tags', tags_type)

for item in ['create', 'update']:
    register_cli_argument('storage account {}'.format(item), 'sku', help='The storage account SKU.', **enum_choice_list(SkuName))
    register_cli_argument('storage account {}'.format(item), 'encryption', nargs='+', help='Specifies which service(s) to encrypt.', validator=validate_encryption, **enum_choice_list(list(EncryptionServices._attribute_map.keys())))  # pylint: disable=protected-access

register_cli_argument('storage account create', 'access_tier', help='Required for StandardBlob accounts. The access tier used for billing. Cannot be set for StandardLRS, StandardGRS, StandardRAGRS, or PremiumLRS account types.', **enum_choice_list(AccessTier))
register_cli_argument('storage account update', 'access_tier', help='The access tier used for billing StandardBlob accounts. Cannot be set for StandardLRS, StandardGRS, StandardRAGRS, or PremiumLRS account types.', **enum_choice_list(AccessTier))
Пример #22
0
with VersionConstraint(ResourceType.MGMT_RESOURCE_POLICY,
                       min_api='2016-12-01') as c:
    from azure.mgmt.resource.policy.models import PolicyMode
    c.register_cli_argument(
        'policy definition',
        'params',
        help=
        'JSON formatted string or a path to a file or uri with parameter definitions',
        type=file_type,
        completer=FilesCompleter())
    c.register_cli_argument('policy definition create',
                            'mode',
                            options_list=('--mode', '-m'),
                            help='mode of the new policy definition.',
                            **enum_choice_list(PolicyMode))

register_cli_argument('policy definition',
                      'display_name',
                      help='display name of policy definition')
register_cli_argument('policy definition',
                      'description',
                      help='description of policy definition')
register_cli_argument('policy assignment',
                      'name',
                      options_list=('--name', '-n'),
                      completer=get_policy_assignment_completion_list,
                      help='name of the assignment')
register_cli_argument('policy assignment create',
                      'name',
                      options_list=('--name', '-n'),
Пример #23
0
)

register_cli_argument('eventgrid', 'resource_group_name', resource_group_name_type)
register_cli_argument('eventgrid', 'location', location_type)
register_cli_argument('eventgrid', 'tags', tags_type, help="Space separated tags in 'key[=value]' format.")

register_cli_argument('eventgrid', '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.")
register_cli_argument('eventgrid', 'event_subscription_name', help="Name of the event subscription.")
register_cli_argument('eventgrid', 'subject_begins_with', help="An optional string to filter events for an event subscription based on a prefix. Wildcard characters are not supported.")
register_cli_argument('eventgrid', 'subject_ends_with', help="An optional string to filter events for an event subscription based on a suffix. Wildcard characters are not supported.")
register_cli_argument('eventgrid', 'topic_type_name', help="Name of the topic type.")


register_cli_argument('eventgrid topic', 'topic_name', arg_type=name_type, help='Name of the topic', id_part="name")
register_cli_argument('eventgrid topic event-subscription', 'topic_name', options_list=['--topic-name'])
register_cli_argument('eventgrid topic event-subscription', 'event_subscription_name', name_type, help='Name of the event subscription')
register_cli_argument('eventgrid event-subscription', 'event_subscription_name', name_type, help='Name of the event subscription')
register_cli_argument('eventgrid resource event-subscription', 'event_subscription_name', name_type, help='Name of the event subscription')

register_cli_argument('eventgrid', 'is_subject_case_sensitive', 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.", **three_state_flag())

register_cli_argument('eventgrid', 'included_event_types', included_event_types_type)
register_cli_argument('eventgrid', 'labels', labels_type)
register_cli_argument('eventgrid', 'endpoint_type', **enum_choice_list(['webhook', 'eventhub']))

register_cli_argument('eventgrid', 'provider_namespace', help="Namespace of the provider owning the resource.")
register_cli_argument('eventgrid', 'resource_type', help="Type of the resource.")
register_cli_argument('eventgrid', 'resource_name', help="Name of the resource whose event subscription needs to be managed.")

register_cli_argument('eventgrid topic-type', 'topic_type_name', name_type)
Пример #24
0
def validate_ip_range_filter(ns):
    if ns.ip_range_filter:
        ns.ip_range_filter = ",".join(ns.ip_range_filter)


register_cli_argument('cosmosdb',
                      'account_name',
                      arg_type=name_type,
                      help='Name of the Cosmos DB database account',
                      completer=get_resource_name_completion_list(
                          'Microsoft.DocumentDb/databaseAccounts'),
                      id_part="name")

register_cli_argument('cosmosdb regenerate-key', 'key_kind',
                      **enum_choice_list(KeyKind))
register_cli_argument(
    'cosmosdb failover-priority-change',
    'failover_policies',
    validator=validate_failover_policies,
    help=
    "space separated failover policies in 'regionName=failoverPriority' format. E.g \"East US\"=0 \"West US\"=1",
    nargs='+')
register_cli_argument('cosmosdb create', 'account_name', completer=None)
register_cli_argument('cosmosdb create',
                      'resource_group_name',
                      help="name of the resource group")
register_cli_argument('cosmosdb create', 'resource_group_location',
                      ignore_type)
register_cli_argument(
    'cosmosdb create',
Пример #25
0
    if system == "Windows":
        program_files = os.environ.get("ProgramFiles")
        if not program_files:
            return None
        install_location = "{}\\{}.exe".format(program_files, exe_name)
    elif system == "Linux" or system == "Darwin":
        install_location = "/usr/local/bin/{}".format(exe_name)
    else:
        install_location = None
    return install_location


name_arg_type = CliArgumentType(options_list=("--name", "-n"), metavar="NAME")

register_cli_argument("acs", "name", arg_type=name_arg_type)
register_cli_argument("acs", "orchestrator_type", **enum_choice_list(ContainerServiceOchestratorTypes))
# some admin names are prohibited in acs, such as root, admin, etc. Because we have no control on the orchestrators, so default to a safe name.
register_cli_argument("acs", "admin_username", options_list=("--admin-username",), default="azureuser", required=False)
register_cli_argument("acs", "dns_name_prefix", options_list=("--dns-prefix", "-d"))
register_cli_argument(
    "acs",
    "container_service_name",
    options_list=("--name", "-n"),
    help="The name of the container service",
    completer=get_resource_name_completion_list("Microsoft.ContainerService/ContainerServices"),
)

register_cli_argument(
    "acs",
    "ssh_key_value",
    required=False,
Пример #26
0
for item in [
        'check-name', 'delete', 'list', 'show', 'show-usage', 'update', 'keys'
]:
    register_cli_argument('storage account {}'.format(item),
                          'account_name',
                          account_name_type,
                          options_list=('--name', '-n'))

register_cli_argument('storage account show-connection-string',
                      'account_name',
                      account_name_type,
                      options_list=('--name', '-n'))
register_cli_argument('storage account show-connection-string',
                      'protocol',
                      help='The default endpoint protocol.',
                      **enum_choice_list(['http', 'https']))
register_cli_argument('storage account show-connection-string',
                      'key_name',
                      options_list=('--key', ),
                      help='The key to use.',
                      **enum_choice_list(
                          list(storage_account_key_options.keys())))
for item in ['blob', 'file', 'queue', 'table']:
    register_cli_argument('storage account show-connection-string',
                          '{}_endpoint'.format(item),
                          help='Custom endpoint for {}s.'.format(item))

register_cli_argument('storage account create',
                      'account_name',
                      account_name_type,
                      options_list=('--name', '-n'),
Пример #27
0
        if not program_files:
            return None
        install_location = '{}\\{}.exe'.format(program_files, exe_name)
    elif system == 'Linux' or system == 'Darwin':
        install_location = '/usr/local/bin/{}'.format(exe_name)
    else:
        install_location = None
    return install_location


name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

register_cli_argument('acs', 'name', arg_type=name_arg_type, help='ACS cluster name', completer=get_resource_name_completion_list('Microsoft.ContainerService/ContainerServices'))
register_cli_argument('acs', 'resource_group', arg_type=resource_group_name_type)

register_cli_argument('acs', 'orchestrator_type', **enum_choice_list(ContainerServiceOchestratorTypes))
# some admin names are prohibited in acs, such as root, admin, etc. Because we have no control on the orchestrators, so default to a safe name.
register_cli_argument('acs', 'admin_username', options_list=('--admin-username',), default='azureuser', required=False)
register_cli_argument('acs', 'dns_name_prefix', options_list=('--dns-prefix', '-d'))
register_cli_argument('acs', 'container_service_name', options_list=('--name', '-n'), help='The name of the container service', completer=get_resource_name_completion_list('Microsoft.ContainerService/ContainerServices'))

register_cli_argument('acs', 'ssh_key_value', required=False, help='SSH key file value or key file path.', type=file_type, default=os.path.join('~', '.ssh', 'id_rsa.pub'), completer=FilesCompleter())
register_cli_argument('acs create', 'name', arg_type=name_arg_type, validator=validate_ssh_key)

register_extra_cli_argument('acs create', 'generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing')
register_cli_argument('acs create', 'agent_vm_size', completer=get_vm_size_completion_list)

register_cli_argument('acs', 'disable_browser', help='Do not open browser after opening a proxy to the cluster web user interface')
register_cli_argument('acs dcos browse', 'name', name_arg_type)
register_cli_argument('acs dcos install-cli', 'install_location',
                      options_list=('--install-location',),
Пример #28
0
register_cli_argument(
    'ad app',
    'available_to_other_tenants',
    action='store_true',
    help='the application can be used from any Azure AD tenants')
register_cli_argument(
    'ad app',
    '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
register_cli_argument(
    'ad app',
    'key_type',
    default='AsymmetricX509Cert',
    help='the type of the key credentials associated with the application',
    **enum_choice_list(['AsymmetricX509Cert', 'Password', 'Symmetric']))
register_cli_argument(
    'ad app',
    'key_usage',
    default='Verify',
    help='the usage of the key credentials associated with the application.',
    **enum_choice_list(['Sign', 'Verify']))

name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

register_cli_argument('ad sp',
                      'identifier',
                      options_list=('--id', ),
                      help='service principal name, or object id')
register_cli_argument(
    'ad sp create',
Пример #29
0
server_completers = {'mysql': get_resource_name_completion_list('Microsoft.DBForMySQL/servers'),
                     'postgres': get_resource_name_completion_list('Microsoft.DBForPostgreSQL/servers')}


for command_group_name in ['mysql', 'postgres']:
    register_cli_argument('{0}'.format(command_group_name), 'name', options_list=('--sku-name',))
    register_cli_argument('{0}'.format(command_group_name), 'server_name', completer=server_completers[command_group_name], options_list=('--server-name', '-s'))

    register_cli_argument('{0} server'.format(command_group_name), 'server_name', options_list=('--name', '-n'), id_part='name',
                          help='Name of the server.')
    register_cli_argument('{0} server'.format(command_group_name), 'administrator_login', options_list=('--admin-user', '-u'))
    register_cli_argument('{0} server'.format(command_group_name), 'administrator_login_password', options_list=('--admin-password', '-p'), required=False,
                          help='The password of the administrator login.')
    register_cli_argument('{0} server'.format(command_group_name), 'ssl_enforcement', options_list=('--ssl-enforcement',),
                          help='Enable ssl enforcement or not when connect to server.',
                          **enum_choice_list(['Enabled', 'Disabled']))
    register_cli_argument('{0} server'.format(command_group_name), 'tier', options_list=('--performance-tier',),
                          help='The performance tier of the server.',
                          **enum_choice_list(['Basic', 'Standard']))
    register_cli_argument('{0} server'.format(command_group_name), 'capacity', options_list=('--compute-units',), type=int,
                          help='Number of compute units.')
    register_cli_argument('{0} server'.format(command_group_name), 'storage_mb', options_list=('--storage-size',), type=int,
                          help='The max storage size of the server, unit is MB.')
    register_cli_argument('{0} server'.format(command_group_name), 'tags', tags_type)

    register_cli_argument('{0} server-logs'.format(command_group_name), 'file_name', options_list=('--name', '-n'), nargs='+')
    register_cli_argument('{0} server-logs'.format(command_group_name), 'max_file_size', type=int)
    register_cli_argument('{0} server-logs'.format(command_group_name), 'file_last_written', type=int)

    register_cli_argument('{0} db'.format(command_group_name), 'database_name', options_list=('--name', '-n'))
Пример #30
0
# Arguments for 'iot hub create'
register_cli_argument('iot hub create', 'hub_name', completer=None)
register_cli_argument(
    'iot hub create',
    'location',
    location_type,
    help=
    'Location of your IoT Hub. Default is the location of target resource group.'
)
register_cli_argument(
    'iot hub create',
    'sku',
    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.',
    **enum_choice_list(IotHubSku))
register_cli_argument('iot hub create',
                      'unit',
                      help='Units in your IoT Hub.',
                      type=int)

# Arguments for 'iot hub show-connection-string'
register_cli_argument('iot hub show-connection-string',
                      'policy_name',
                      help='Shared access policy to use.')
register_cli_argument('iot hub show-connection-string',
                      'key_type',
                      options_list=('--key', ),
                      help='The key to use.',
                      **enum_choice_list(KeyType))
Пример #31
0
                if extra_parameter is None else m(resource_group_name, name, extra_parameter, slot))

def get_hostname_completion_list(prefix, action, parsed_args, **kwargs): # pylint: disable=unused-argument
    if parsed_args.resource_group_name and parsed_args.webapp:
        rg = parsed_args.resource_group_name
        webapp = parsed_args.webapp
        slot = getattr(parsed_args, 'slot', None)
        result = _generic_site_operation(rg, webapp, 'get_site_host_name_bindings', slot)
        #workaround an api defect, that 'name' is '<webapp>/<hostname>'
        return [r.name.split('/', 1)[1] for r in result]

#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), etc',
                               **enum_choice_list(['F1', 'FREE', 'D1', 'SHARED', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3']))

register_cli_argument('appservice', 'resource_group_name', arg_type=resource_group_name_type)
register_cli_argument('appservice', 'location', arg_type=location_type)

register_cli_argument('appservice list-locations', 'linux_workers_enabled', action='store_true', help='get regions which support hosting webapps on Linux workers')
register_cli_argument('appservice plan', 'name', arg_type=name_arg_type, help='The name of the app service plan', completer=get_resource_name_completion_list('Microsoft.Web/serverFarms'), id_part='name')
register_cli_argument('appservice plan create', 'name', options_list=('--name', '-n'), help="Name of the new app service plan")
register_cli_argument('appservice plan create', 'sku', arg_type=sku_arg_type)
register_cli_argument('appservice plan create', 'is_linux', action='store_true', required=False, help='host webapp on Linux worker')
register_cli_argument('appservice plan update', 'sku', arg_type=sku_arg_type)
register_cli_argument('appservice plan update', 'allow_pending_state', ignore_type)
register_cli_argument('appservice plan', 'number_of_workers', help='Number of workers to be allocated.', type=int, default=1)
register_cli_argument('appservice plan', 'admin_site_name', help='The name of the admin web app.')

register_cli_argument('appservice web', 'slot', help="the name of the slot. Default to the productions slot if not specified")
Пример #32
0
        '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 ParametersContext(command='sql db export') as c:
    c.expand('parameters', ExportRequest)
    c.register_alias('administrator_login', ('--admin-user', '-u'))
    c.register_alias('administrator_login_password',
                     ('--admin-password', '-p'))
    c.argument('authentication_type',
               options_list=('--auth-type', ),
               **enum_choice_list(AuthenticationType))
    c.argument('storage_key_type', **enum_choice_list(StorageKeyType))

with ParametersContext(command='sql db import') as c:
    c.expand('parameters', ImportExtensionRequest)
    c.register_alias('administrator_login', ('--admin-user', '-u'))
    c.register_alias('administrator_login_password',
                     ('--admin-password', '-p'))
    c.argument('authentication_type',
               options_list=('--auth-type', ),
               **enum_choice_list(AuthenticationType))
    c.argument('storage_key_type', **enum_choice_list(StorageKeyType))

    c.ignore('type')

    # The parameter name '--name' is used for 'database_name', so we need to give a different name
Пример #33
0
        return list_traffic_manager_endpoints(parsed_args.resource_group_name, parsed_args.profile_name) \
            if parsed_args.resource_group_name and parsed_args.profile_name \
            else []
    return completer

# BASIC PARAMETER CONFIGURATION

name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')
nic_type = CliArgumentType(options_list=('--nic-name',), metavar='NIC_NAME', help='The network interface (NIC).', id_part='name', completer=get_resource_name_completion_list('Microsoft.Network/networkInterfaces'))
nsg_name_type = CliArgumentType(options_list=('--nsg-name',), metavar='NSG', help='Name of the network security group.')
circuit_name_type = CliArgumentType(options_list=('--circuit-name',), metavar='CIRCUIT', help='ExpressRoute circuit name.', id_part='name', completer=get_resource_name_completion_list('Microsoft.Network/expressRouteCircuits'))
virtual_network_name_type = CliArgumentType(options_list=('--vnet-name',), metavar='VNET_NAME', help='The virtual network (VNET) name.', completer=get_resource_name_completion_list('Microsoft.Network/virtualNetworks'))
subnet_name_type = CliArgumentType(options_list=('--subnet-name',), metavar='SUBNET_NAME', help='The subnet name.')
load_balancer_name_type = CliArgumentType(options_list=('--lb-name',), metavar='LB_NAME', help='The load balancer name.', completer=get_resource_name_completion_list('Microsoft.Network/loadBalancers'), id_part='name')
private_ip_address_type = CliArgumentType(help='Static private IP address to use.', validator=validate_private_ip_address)
cookie_based_affinity_type = CliArgumentType(**enum_choice_list(ApplicationGatewayCookieBasedAffinity))
http_protocol_type = CliArgumentType(**enum_choice_list(ApplicationGatewayProtocol))

register_cli_argument('network', 'subnet_name', subnet_name_type)
register_cli_argument('network', 'virtual_network_name', virtual_network_name_type, id_part='name')
register_cli_argument('network', 'network_security_group_name', nsg_name_type, id_part='name')
register_cli_argument('network', 'private_ip_address', private_ip_address_type)
register_cli_argument('network', 'private_ip_address_allocation', help=argparse.SUPPRESS)
register_cli_argument('network', 'private_ip_address_version', **enum_choice_list(privateIpAddressVersion))
register_cli_argument('network', 'tags', tags_type)

for item in ['lb', 'nic']:
    register_cli_argument('network {}'.format(item), 'subnet', validator=validate_subnet_name_or_id, help='Name or ID of an existing subnet.')
    register_cli_argument('network {}'.format(item), 'virtual_network_name', help='The virtual network (VNet) associated with the provided subnet name (Omit if supplying a subnet id).', id_part=None)
    register_cli_argument('network {}'.format(item), 'public_ip_address', validator=validate_public_ip_name_or_id)
Пример #34
0
                      required=True,
                      help='The deployment name.')
register_cli_argument('group deployment',
                      'template_file',
                      completer=FilesCompleter(),
                      type=file_type,
                      help="a template file path in the file system")
register_cli_argument('group deployment',
                      'template_uri',
                      help='a uri to a remote template file')
register_cli_argument(
    'group deployment',
    'mode',
    help=
    'Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)',
    **enum_choice_list(DeploymentMode))

register_cli_argument(
    'group deployment create',
    'deployment_name',
    options_list=('--name', '-n'),
    required=False,
    validator=process_deployment_create_namespace,
    help='The deployment name. Default to template file base name')
register_cli_argument('group deployment',
                      'parameters',
                      action='append',
                      nargs='+',
                      completer=FilesCompleter())

register_cli_argument('group deployment operation show',
Пример #35
0
# ARGUMENT DEFINITIONS

vault_name_type = CliArgumentType(help='Name of the key vault.', options_list=('--vault-name',), completer=get_resource_name_completion_list('Microsoft.KeyVault/vaults'), id_part=None)

# PARAMETER REGISTRATIONS

register_cli_argument('keyvault', 'resource_group_name', resource_group_name_type, id_part=None, required=False, help='Proceed only if Key Vault belongs to the specified resource group.', validator=validate_resource_group_name)
register_cli_argument('keyvault', 'vault_name', vault_name_type, options_list=('--name', '-n'))
register_cli_argument('keyvault', 'object_id', help='a GUID that identifies the principal that will receive permissions')
register_cli_argument('keyvault', 'spn', help='name of a service principal that will receive permissions')
register_cli_argument('keyvault', 'upn', help='name of a user principal that will receive permissions')
register_cli_argument('keyvault', 'tags', tags_type)

register_cli_argument('keyvault create', 'resource_group_name', resource_group_name_type, completer=None, validator=None)
register_cli_argument('keyvault create', 'vault_name', completer=None)
register_cli_argument('keyvault create', 'sku', **enum_choice_list(SkuName))
register_cli_argument('keyvault create', 'no_self_perms', action='store_true', help="If specified, don't add permissions for the current user in the new vault")

register_cli_argument('keyvault list', 'resource_group_name', resource_group_name_type, validator=None)

register_cli_argument('keyvault delete-policy', 'object_id', validator=validate_principal)
register_cli_argument('keyvault set-policy', 'key_permissions', metavar='PERM', nargs='*', help='Space separated list. Possible values: {}'.format(key_permission_values), arg_group='Permission', validator=validate_policy_permissions)
register_cli_argument('keyvault set-policy', 'secret_permissions', metavar='PERM', nargs='*', help='Space separated list. Possible values: {}'.format(secret_permission_values), arg_group='Permission')
register_cli_argument('keyvault set-policy', 'certificate_permissions', metavar='PERM', nargs='*', help='Space separated list. Possible values: {}'.format(certificate_permission_values), arg_group='Permission')

for item in ['key', 'secret', 'certificate']:
    register_cli_argument('keyvault {}'.format(item), '{}_name'.format(item), options_list=('--name', '-n'), help='Name of the {}.'.format(item), id_part='child_name', completer=get_keyvault_name_completion_list(item))
    register_cli_argument('keyvault {}'.format(item), 'vault_base_url', vault_name_type, type=vault_base_url_type, id_part=None)
# TODO: Fix once service side issue is fixed that there is no way to list pending certificates
register_cli_argument('keyvault certificate pending', 'certificate_name', options_list=('--name', '-n'), help='Name of the pending certificate.', id_part='child_name', completer=None)
Пример #36
0
    def __init__(self, value):
        super(ScheduleEntryList, self).__init__()
        if value[0] in ("'", '"') and value[-1] == value[0]:
            # Remove leading and trailing quotes for dos/cmd.exe users
            value = value[1:-1]
        dictval = shell_safe_json_parse(value)
        self.extend([ScheduleEntry(row['dayOfWeek'],
                                   int(row['startHourUtc']),
                                   row.get('maintenanceWindow', None)) for row in dictval])


register_cli_argument('redis', 'name', arg_type=name_type, help='Name of the redis cache.',
                      completer=get_resource_name_completion_list('Microsoft.Cache/redis'),
                      id_part='name')
register_cli_argument('redis', 'redis_configuration', type=JsonString)
register_cli_argument('redis', 'reboot_type', **enum_choice_list(RebootType))
register_cli_argument('redis', 'key_type', **enum_choice_list(RedisKeyType))
register_cli_argument('redis', 'shard_id', type=int)
register_cli_argument('redis', 'sku', **enum_choice_list(SkuName))
register_cli_argument('redis', 'vm_size',
                      help='Size of redis cache to deploy. '
                           'Example : values for C family (C0, C1, C2, C3, C4, C5, C6). '
                           'For P family (P1, P2, P3, P4)')
register_cli_argument('redis', 'enable_non_ssl_port', action='store_true')
register_cli_argument('redis', 'shard_count', type=int)
register_cli_argument('redis', 'subnet_id')

register_cli_argument('redis import-method', 'files', nargs='+')

register_cli_argument('redis patch-schedule set', 'schedule_entries', type=ScheduleEntryList)
Пример #37
0
register_cli_argument('monitor', 'location', location_type, validator=get_default_location_from_resource_group)
register_cli_argument('monitor', 'tags', tags_type)

# region Alerts

register_cli_argument('monitor alert', 'rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')

register_cli_argument('monitor alert create', 'rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')

register_cli_argument('monitor alert create', 'custom_emails', nargs='+', arg_group='Action')
register_cli_argument('monitor alert create', 'disabled', **three_state_flag())
register_cli_argument('monitor alert create', 'email_service_owners', arg_group='Action', **three_state_flag())
register_cli_argument('monitor alert create', 'actions', options_list=['--action', '-a'], action=AlertAddAction, nargs='+', arg_group='Action')
register_cli_argument('monitor alert create', 'condition', action=ConditionAction, nargs='+')
register_cli_argument('monitor alert create', 'metric_name', arg_group='Condition')
register_cli_argument('monitor alert create', 'operator', arg_group='Condition', **enum_choice_list(ConditionOperator))
register_cli_argument('monitor alert create', 'threshold', arg_group='Condition')
register_cli_argument('monitor alert create', 'time_aggregation', arg_group='Condition', **enum_choice_list(TimeAggregationOperator))
register_cli_argument('monitor alert create', 'window_size', arg_group='Condition')
register_resource_parameter('monitor alert create', 'target', 'Target Resource')

register_cli_argument('monitor alert update', 'rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
register_cli_argument('monitor alert update', 'email_service_owners', arg_group='Action', **three_state_flag())
register_cli_argument('monitor alert update', 'add_actions', options_list=['--add-action', '-a'], nargs='+', action=AlertAddAction, arg_group='Action')
register_cli_argument('monitor alert update', 'remove_actions', options_list=['--remove-action', '-r'], nargs='+', action=AlertRemoveAction, arg_group='Action')
register_cli_argument('monitor alert update', 'condition', action=ConditionAction, nargs='+', arg_group='Condition')
register_cli_argument('monitor alert update', 'metric', arg_group='Condition')
register_cli_argument('monitor alert update', 'operator', arg_group='Condition', **enum_choice_list(operator_map.keys()))
register_cli_argument('monitor alert update', 'threshold', arg_group='Condition')
register_cli_argument('monitor alert update', 'aggregation', arg_group='Condition', **enum_choice_list(aggregation_map.keys()))
register_cli_argument('monitor alert update', 'period', type=period_type, arg_group='Condition')
Пример #38
0
    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')
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(required=False,
                           help='underlying storage sku',
                           **enum_choice_list(['Premium_LRS', 'Standard_LRS']))

# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
register_cli_argument('vm', 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

for item in ['show', 'list']:
    register_cli_argument(
        'vm {}'.format(item),
        'show_details',
        action='store_true',
        options_list=('--show-details', '-d'),
        help=
Пример #39
0
    def __init__(self, value):
        super(ScheduleEntryList, self).__init__()
        import json
        if value[0] in ("'", '"') and value[-1] == value[0]:
            # Remove leading and trailing quotes for dos/cmd.exe users
            value = value[1:-1]
        dictval = json.loads(value)
        self.extend([ScheduleEntry(
            row['dayOfWeek'],
            int(row['startHourUtc']),
            row.get('maintenanceWindow', None))
                     for row in dictval])

register_cli_argument('redis', 'name', arg_type=name_type, help='Name of the redis cache.', completer=get_resource_name_completion_list('Microsoft.Cache/redis'), id_part='name')
register_cli_argument('redis', 'redis_configuration', type=JsonString)
register_cli_argument('redis', 'reboot_type', **enum_choice_list(RebootType))
register_cli_argument('redis', 'key_type', **enum_choice_list(RedisKeyType))
register_cli_argument('redis', 'shard_id', type=int)
register_cli_argument('redis import-method', 'files', nargs='+')

register_cli_argument('redis patch-schedule set', 'schedule_entries', type=ScheduleEntryList)

register_cli_argument('redis create', 'name', arg_type=name_type, completer=None)
register_cli_argument('redis create', 'sku_name', **enum_choice_list(SkuName))
register_cli_argument('redis create', 'sku_family', **enum_choice_list(SkuFamily))
register_cli_argument('redis create', 'sku_capacity', choices=[str(n) for n in range(0, 7)])
register_cli_argument('redis create', 'enable_non_ssl_port', action='store_true')
register_cli_argument('redis create', 'tenant_settings', type=JsonString)
register_cli_argument('redis create', 'shard_count', type=int)
register_cli_argument('redis create', 'subnet_id') # TODO: Create generic id completer similar to name
Пример #40
0

# 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')
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(required=False, help='underlying storage sku', **enum_choice_list(['Premium_LRS', 'Standard_LRS']))

# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
for scope in ['vm', 'disk', 'snapshot', 'image']:
    register_cli_argument(scope, 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

for item in ['show', 'list']:
    register_cli_argument('vm {}'.format(item), 'show_details', action='store_true', options_list=('--show-details', '-d'), help='show public ip address, FQDN, and power states. command will run slow')

register_cli_argument('vm unmanaged-disk', 'vm_name', arg_type=existing_vm_name)
register_cli_argument('vm unmanaged-disk attach', 'disk_name', options_list=('--name', '-n'), help='The data disk name(optional when create a new disk)')
register_cli_argument('vm unmanaged-disk detach', 'disk_name', options_list=('--name', '-n'), help='The data disk name.')
Пример #41
0
        self.extend([
            ScheduleEntry(row['dayOfWeek'], int(row['startHourUtc']),
                          row.get('maintenanceWindow', None))
            for row in dictval
        ])


register_cli_argument(
    'redis',
    'name',
    arg_type=name_type,
    help='Name of the redis cache.',
    completer=get_resource_name_completion_list('Microsoft.Cache/redis'),
    id_part='name')
register_cli_argument('redis', 'redis_configuration', type=JsonString)
register_cli_argument('redis', 'reboot_type', **enum_choice_list(RebootType))
register_cli_argument('redis', 'key_type', **enum_choice_list(RedisKeyType))
register_cli_argument('redis', 'shard_id', type=int)
register_cli_argument('redis', 'sku', **enum_choice_list(SkuName))
register_cli_argument(
    'redis',
    'vm_size',
    help='Size of redis cache to deploy. '
    'Example : values for C family (C0, C1, C2, C3, C4, C5, C6). '
    'For P family (P1, P2, P3, P4)')
register_cli_argument('redis', 'enable_non_ssl_port', action='store_true')
register_cli_argument('redis', 'shard_count', type=int)
register_cli_argument('redis', 'subnet_id')

register_cli_argument('redis import-method', 'files', nargs='+')
Пример #42
0
# Arguments for 'iot hub policy' group
register_cli_argument('iot hub policy', 'policy_name', options_list=('--name', '-n'), help='Share access policy name.')

# Arguments for 'iot hub job' group
register_cli_argument('iot hub job', 'job_id', help='Job Id.')

# Arguments for 'iot hub create'
register_cli_argument('iot hub create', 'hub_name', completer=None)
register_cli_argument('iot hub create', 'location', location_type,
                      help='Location of your IoT Hub. Default is the location of target resource group.')
register_cli_argument('iot hub create', 'sku',
                      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.',
                      **enum_choice_list(IotHubSku))
register_cli_argument('iot hub create', 'unit', help='Units in your IoT Hub.', type=int)

# Arguments for 'iot hub show-connection-string'
register_cli_argument('iot hub show-connection-string', 'policy_name', help='Shared access policy to use.')
register_cli_argument('iot hub show-connection-string', 'key_type', options_list=('--key',), help='The key to use.',
                      **enum_choice_list(KeyType))

# Arguments for 'iot device create'
register_cli_argument('iot device create', 'device_id', completer=None)
register_cli_argument('iot device create', 'x509', action='store_true', arg_group='X.509 Certificate',
                      help='Use X.509 certificate for device authentication.')
register_cli_argument('iot device create', 'primary_thumbprint', arg_group='X.509 Certificate',
                      help='Primary X.509 certificate thumbprint to authenticate device.')
register_cli_argument('iot device create', 'secondary_thumbprint', arg_group='X.509 Certificate',
                      help='Secondary X.509 certificate thumbprint to authenticate device.')
Пример #43
0
register_cli_argument('keyvault', 'enabled_for_deployment',
                      help='Allow Virtual Machines to retrieve certificates stored as secrets from '
                           'the vault.',
                      **three_state_flag())
register_cli_argument('keyvault', 'enabled_for_disk_encryption',
                      help='Allow Disk Encryption to retrieve secrets from the vault and unwrap '
                           'keys.',
                      **three_state_flag())
register_cli_argument('keyvault', 'enabled_for_template_deployment',
                      help='Allow Resource Manager to retrieve secrets from the vault.',
                      **three_state_flag())

register_cli_argument('keyvault create', 'resource_group_name', resource_group_name_type,
                      required=True, completer=None, validator=None)
register_cli_argument('keyvault create', 'vault_name', completer=None)
register_cli_argument('keyvault create', 'sku', **enum_choice_list(SkuName))
register_cli_argument('keyvault create', 'no_self_perms',
                      help="Don't add permissions for the current user/service principal in the "
                           "new vault",
                      **three_state_flag())
register_cli_argument('keyvault create', 'location',
                      validator=get_default_location_from_resource_group)

register_cli_argument('keyvault list', 'resource_group_name', resource_group_name_type,
                      validator=None)

register_cli_argument('keyvault delete-policy', 'object_id', validator=validate_principal)
register_cli_argument('keyvault set-policy', 'key_permissions', metavar='PERM', nargs='*',
                      help='Space separated list. Possible values: {}'.format(
                          key_permission_values), arg_group='Permission',
                      validator=validate_policy_permissions)
Пример #44
0
# ARGUMENT DEFINITIONS

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)

# PARAMETER REGISTRATIONS

register_cli_argument('batch', 'resource_group_name', resource_group_name_type, help='Name of the resource group', completer=None, validator=None)
register_cli_argument('batch account', 'account_name', batch_name_type, options_list=('--name', '-n'))
register_cli_argument('batch account create', 'location', location_type, help='The region in which to create the account.')
register_cli_argument('batch account create', 'tags', tags_type, help="Space separated tags in 'key[=value]' format.")
register_cli_argument('batch account create', 'storage_account', help='The storage account name or resource ID to be used for auto storage.', validator=storage_account_id)
register_cli_argument('batch account create', '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)
register_cli_argument('batch account create', 'keyvault_url', ignore_type)
register_cli_argument('batch account set', 'tags', tags_type)
register_cli_argument('batch account set', 'storage_account', help='The storage account name or resource ID to be used for auto storage.', validator=storage_account_id)
register_cli_argument('batch account keys renew', 'key_name', **enum_choice_list(AccountKeyType))
register_cli_argument('batch account login', 'shared_key_auth', action='store_true', help='Using Shared Key authentication, if not specified, it will use Azure Active Directory authentication.')

register_cli_argument('batch application set', 'application_id', options_list=('--application-id',), help="The ID of the application.")
register_cli_argument('batch application set', '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.")
register_cli_argument('batch application create', '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.")
register_cli_argument('batch application package create', 'package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter())
register_cli_argument('batch application package create', 'application_id', options_list=('--application-id',), help="The ID of the application.")
register_cli_argument('batch application package create', 'version', options_list=('--version',), help="The version of the application.")
register_cli_argument('batch location quotas show', 'location_name', location_type, help='The region from which to display the Batch service quotas.')

for command in ['list', 'show', 'create', 'set', 'delete', 'package']:
    register_cli_argument('batch application {}'.format(command), 'account_name', batch_name_type, options_list=('--name', '-n'), validator=application_enabled)

# TODO: Refactor so the help text can be extracted automatically
register_cli_argument('batch pool resize', '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')
Пример #45
0
    else:
        install_location = None
    return install_location


name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

register_cli_argument('acs', 'tags', tags_type)

register_cli_argument('acs', 'name', arg_type=name_arg_type, configured_default='acs',
                      help="ACS cluster name. You can configure the default using `az configure --defaults acs=<name>`",
                      completer=get_resource_name_completion_list('Microsoft.ContainerService/ContainerServices'))

register_cli_argument('acs', 'resource_group', arg_type=resource_group_name_type)

register_cli_argument('acs', 'orchestrator_type', options_list=('--orchestrator-type', '-t'), **enum_choice_list(ContainerServiceOchestratorTypes))
# some admin names are prohibited in acs, such as root, admin, etc. Because we have no control on the orchestrators, so default to a safe name.
register_cli_argument('acs', 'admin_username', options_list=('--admin-username',), default='azureuser', required=False)
register_cli_argument('acs', 'dns_name_prefix', options_list=('--dns-prefix', '-d'))
register_cli_argument('acs', 'container_service_name', options_list=('--name', '-n'), help='The name of the container service', completer=get_resource_name_completion_list('Microsoft.ContainerService/ContainerServices'))

register_cli_argument('acs', 'ssh_key_value', required=False, help='SSH key file value or key file path.', type=file_type, default=os.path.join('~', '.ssh', 'id_rsa.pub'), completer=FilesCompleter())
register_cli_argument('acs create', 'name', arg_type=name_arg_type, validator=validate_ssh_key)

register_extra_cli_argument('acs create', 'generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing')
register_cli_argument('acs create', 'agent_vm_size', completer=get_vm_size_completion_list)

register_cli_argument('acs create', 'windows', action='store_true', help='If true, deploy a windows container cluster.')
register_cli_argument('acs create', 'validate', action='store_true', help='Generate and validate the ARM template without creating any resources')

Пример #46
0
# ARGUMENT DEFINITIONS
# pylint: disable=line-too-long
datalake_analytics_name_type = CliArgumentType(help='Name of the Data Lake Analytics account.', options_list=('--account_name',), completer=get_resource_name_completion_list('Microsoft.DataLakeAnalytics/accounts'), id_part='name')

# PARAMETER REGISTRATIONS
# data lake analytics common params
register_cli_argument('dla', 'resource_group_name', resource_group_name_type, id_part=None, required=False, help='If not specified, will attempt to discover the resource group for the specified Data Lake Analytics account.', validator=validate_resource_group_name)
register_cli_argument('dla', 'top', help='Maximum number of items to return.', type=int)
register_cli_argument('dla', 'skip', help='The number of items to skip over before returning elements.', type=int)
register_cli_argument('dla', 'count', help='The Boolean value of true or false to request a count of the matching resources included with the resources in the response, e.g. Categories?$count=true.', type=bool)

# account params
register_cli_argument('dla', 'account_name', datalake_analytics_name_type, options_list=('--account', '-n'))
register_cli_argument('dla account', 'tags', tags_type)
register_cli_argument('dla account', 'tier', help='The desired commitment tier for this account to use.', **enum_choice_list(TierType))
register_cli_argument('dla account create', 'resource_group_name', resource_group_name_type, validator=None)
register_cli_argument('dla account create', 'account_name', datalake_analytics_name_type, options_list=('--account', '-n'), completer=None)
register_cli_argument('dla account update', 'firewall_state', help='Enable/disable existing firewall rules.', **enum_choice_list(FirewallState))
register_cli_argument('dla account update', 'allow_azure_ips', help='Allow/block Azure originating IPs through the firewall', **enum_choice_list(FirewallAllowAzureIpsState))
register_cli_argument('dla account update', 'max_job_count', help='The maximum supported jobs running under the account at the same time.', type=int)
register_cli_argument('dla account update', 'max_degree_of_parallelism', help='The maximum supported degree of parallelism for this account.', type=int)
register_cli_argument('dla account update', 'query_store_retention', help='The number of days that job metadata is retained.', type=int)
register_cli_argument('dla account list', 'resource_group_name', resource_group_name_type, validator=None)

# storage parameters
register_cli_argument('dla account blob-storage', 'access_key', help='the access key associated with this Azure Storage account that will be used to connect to it')
register_cli_argument('dla account blob-storage', 'suffix', help='the optional suffix for the storage account')

# Job params
# pylint: disable=line-too-long
Пример #47
0
                      'vm_sku',
                      options_list=('--vm-sku'),
                      help='The Vm Sku')
register_cli_argument(
    'sf',
    'vm_user_name',
    options_list=('--vm-user-name'),
    help='The user name for logging to Vm. Default will be adminuser')
register_cli_argument(
    'sf',
    'vm_os',
    default='WindowsServer2016Datacenter',
    options_list=('--vm-os', '--os'),
    help='The Operating System of the VMs that make up the cluster.',
    **enum_choice_list([
        'WindowsServer2012R2Datacenter', 'WindowsServer2016Datacenter',
        'WindowsServer2016DatacenterwithContainers', 'UbuntuServer1604'
    ]))

register_cli_argument('sf client certificate',
                      'certificate_common_name',
                      help='client certificate common name.')
register_cli_argument(
    'sf client certificate',
    'admin_client_thumbprints',
    nargs='+',
    help=
    'Space separated list of client certificate thumbprint that only has admin permission, '
)
register_cli_argument('sf client certificate',
                      'certificate_issuer_thumbprint',
                      help='client certificate issuer thumbprint.')
Пример #48
0
# pylint: disable=line-too-long
datalake_store_name_type = CliArgumentType(help='Name of the Data Lake Store account.', options_list=('--account_name',), completer=get_resource_name_completion_list('Microsoft.DataLakeStore/accounts'), id_part='name')

# PARAMETER REGISTRATIONS
# global params
register_cli_argument('dls', 'account_name', datalake_store_name_type, options_list=('--account', '-n'))
register_cli_argument('dls', 'top', help='Maximum number of items to return.', type=int)
register_cli_argument('dls', 'skip', help='The number of items to skip over before returning elements.', type=int)
register_cli_argument('dls', 'count', help='The Boolean value of true or false to request a count of the matching resources included with the resources in the response, e.g. Categories?$count=true.', type=bool)
# global account params
register_cli_argument('dls account', 'tags', tags_type)
register_cli_argument('dls account', 'resource_group_name', resource_group_name_type, id_part=None, required=False, help='If not specified, will attempt to discover the resource group for the specified Data Lake Store account.', validator=validate_resource_group_name)
# account params
register_cli_argument('dls account show', 'name', datalake_store_name_type, options_list=('--account', '-n'))
register_cli_argument('dls account delete', 'name', datalake_store_name_type, options_list=('--account', '-n'))
register_cli_argument('dls account', 'tier', help='The desired commitment tier for this account to use.', **enum_choice_list(TierType))
register_cli_argument('dls account create', 'resource_group_name', resource_group_name_type, validator=None)
register_cli_argument('dls account create', 'account_name', datalake_store_name_type, options_list=('--account', '-n'), completer=None)
register_cli_argument('dls account create', 'encryption_type', help='Indicates what type of encryption to provision the account with. By default, encryption is ServiceManaged. If no encryption is desired, it must be explicitly set with the --disable-encryption flag.', **enum_choice_list(EncryptionConfigType))
register_cli_argument('dls account create', 'disable_encryption', help='Indicates that the account will not have any form of encryption applied to it.', action='store_true')
register_cli_argument('dls account update', 'trusted_id_provider_state', help='Enable/disable the existing trusted ID providers.', **enum_choice_list(TrustedIdProviderState))
register_cli_argument('dls account update', 'firewall_state', help='Enable/disable existing firewall rules.', **enum_choice_list(FirewallState))
register_cli_argument('dls account update', 'allow_azure_ips', help='Allow/block Azure originating IPs through the firewall', **enum_choice_list(FirewallAllowAzureIpsState))
register_cli_argument('dls account list', 'resource_group_name', resource_group_name_type, validator=None)

# filesystem params
register_cli_argument('dls fs', 'path', help='The path in the specified Data Lake Store account where the action should take place. In the format \'/folder/file.txt\', where the first \'/\' after the DNS indicates the root of the file system.')
register_cli_argument('dls fs create', 'force', help='Indicates that, if the file or folder exists, it should be overwritten', action='store_true')
register_cli_argument('dls fs create', 'folder', help='Indicates that this new item is a folder and not a file.', action='store_true')
register_cli_argument('dls fs delete', 'recurse', help='Indicates this should be a recursive delete of the folder.', action='store_true')
register_cli_argument('dls fs upload', 'overwrite', help='Indicates that, if the destination file or folder exists, it should be overwritten', action='store_true')
Пример #49
0
def get_hostname_completion_list(prefix, action, parsed_args, **kwargs):  # pylint: disable=unused-argument
    if parsed_args.resource_group_name and parsed_args.webapp:
        rg = parsed_args.resource_group_name
        webapp = parsed_args.webapp
        slot = getattr(parsed_args, 'slot', None)
        result = _generic_site_operation(rg, webapp, 'get_site_host_name_bindings', slot)
        # workaround an api defect, that 'name' is '<webapp>/<hostname>'
        return [r.name.split('/', 1)[1] for r in result]


# 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), etc',
                               **enum_choice_list(['F1', 'FREE', 'D1', 'SHARED', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3']))
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
register_cli_argument('webapp', 'app_instance', ignore_type)
register_cli_argument('functionapp', 'app_instance', ignore_type)
# function app doesn't have slot support
register_cli_argument('functionapp', 'slot', ignore_type)

register_cli_argument('appservice', 'resource_group_name', arg_type=resource_group_name_type)
register_cli_argument('appservice', 'location', arg_type=location_type)

register_cli_argument('appservice list-locations', 'linux_workers_enabled', action='store_true', help='get regions which support hosting webapps on Linux workers')
Пример #50
0
                      options_list=('--name', '-n'),
                      completer=None)
register_cli_argument(
    'iot hub create',
    'location',
    location_type,
    help=
    'Location of your IoT Hub. Default is the location of target resource group.'
)
register_cli_argument(
    'iot hub create',
    'sku',
    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.',
    **enum_choice_list(IotHubSku))
register_cli_argument('iot hub create',
                      'unit',
                      help='Units in your IoT Hub.',
                      type=int)

# Arguments for 'iot hub show-connection-string'
register_cli_argument('iot hub show-connection-string',
                      'policy_name',
                      help='Shared access policy to use.')

# Arguments for 'iot device create'
register_cli_argument('iot device create', 'device_id', completer=None)
register_cli_argument('iot device create',
                      'x509',
                      action='store_true',
Пример #51
0
    'Allow Disk Encryption to retrieve secrets from the vault and unwrap keys.',
    **three_state_flag())
register_cli_argument(
    'keyvault',
    'enabled_for_template_deployment',
    help='Allow Resource Manager to retrieve secrets from the vault.',
    **three_state_flag())

register_cli_argument('keyvault create',
                      'resource_group_name',
                      resource_group_name_type,
                      required=True,
                      completer=None,
                      validator=None)
register_cli_argument('keyvault create', 'vault_name', completer=None)
register_cli_argument('keyvault create', 'sku', **enum_choice_list(SkuName))
register_cli_argument(
    'keyvault create',
    'no_self_perms',
    help=
    "Don't add permissions for the current user/service principal in the new vault",
    **three_state_flag())
register_cli_argument('keyvault create',
                      'location',
                      validator=get_default_location_from_resource_group)

register_cli_argument('keyvault list',
                      'resource_group_name',
                      resource_group_name_type,
                      validator=None)
Пример #52
0
    'name',
    arg_type=name_arg_type,
    configured_default='acs',
    help=
    "ACS cluster name. You can configure the default using `az configure --defaults acs=<name>`",
    completer=get_resource_name_completion_list(
        'Microsoft.ContainerService/ContainerServices'))

register_cli_argument('acs',
                      'resource_group',
                      arg_type=resource_group_name_type)

register_cli_argument('acs',
                      'orchestrator_type',
                      options_list=('--orchestrator-type', '-t'),
                      **enum_choice_list(ContainerServiceOrchestratorTypes))
# some admin names are prohibited in acs, such as root, admin, etc. Because we have no control on the orchestrators, so default to a safe name.
register_cli_argument('acs',
                      'admin_username',
                      options_list=('--admin-username', ),
                      default='azureuser',
                      required=False)
register_cli_argument('acs',
                      'dns_name_prefix',
                      options_list=('--dns-prefix', '-d'))
register_cli_argument('acs',
                      'container_service_name',
                      options_list=('--name', '-n'),
                      help='The name of the container service',
                      completer=get_resource_name_completion_list(
                          'Microsoft.ContainerService/ContainerServices'))
Пример #53
0
register_cli_argument('storage', 'progress_callback', ignore_type)
register_cli_argument('storage', 'metadata', nargs='+', help='Metadata in space-separated key=value pairs. This overwrites any existing metadata.', validator=validate_metadata)
register_cli_argument('storage', 'timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

register_cli_argument('storage', 'if_modified_since', help='Alter only if modified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')', type=get_datetime_type(False), arg_group='Pre-condition')
register_cli_argument('storage', 'if_unmodified_since', help='Alter only if unmodified since supplied UTC datetime (Y-m-d\'T\'H:M\'Z\')', type=get_datetime_type(False), arg_group='Pre-condition')
register_cli_argument('storage', 'if_match', arg_group='Pre-condition')
register_cli_argument('storage', 'if_none_match', arg_group='Pre-condition')

register_cli_argument('storage', 'container_name', container_name_type)

for item in ['check-name', 'delete', 'list', 'show', 'show-usage', 'update', 'keys']:
    register_cli_argument('storage account {}'.format(item), 'account_name', account_name_type, options_list=('--name', '-n'))

register_cli_argument('storage account show-connection-string', 'account_name', account_name_type, options_list=('--name', '-n'))
register_cli_argument('storage account show-connection-string', 'protocol', help='The default endpoint protocol.', **enum_choice_list(['http', 'https']))
register_cli_argument('storage account show-connection-string', 'key_name', options_list=('--key',), help='The key to use.', **enum_choice_list(list(storage_account_key_options.keys())))
for item in ['blob', 'file', 'queue', 'table']:
    register_cli_argument('storage account show-connection-string', '{}_endpoint'.format(item), help='Custom endpoint for {}s.'.format(item))

register_cli_argument('storage account create', 'location', location_type, validator=get_default_location_from_resource_group)
register_cli_argument('storage account create', 'account_type', help='The storage account type', **model_choice_list(ResourceType.MGMT_STORAGE, 'AccountType'))

register_cli_argument('storage account create', 'account_name', account_name_type, options_list=('--name', '-n'), completer=None)

register_cli_argument('storage account create', 'kind', help='Indicates the type of storage account.', default=enum_default(ResourceType.MGMT_STORAGE, 'Kind', 'storage'), **model_choice_list(ResourceType.MGMT_STORAGE, 'Kind'))
register_cli_argument('storage account create', 'tags', tags_type)

for item in ['create', 'update']:
    register_cli_argument('storage account {}'.format(item), 'sku', help='The storage account SKU.', **model_choice_list(ResourceType.MGMT_STORAGE, 'SkuName'))
    es_model = get_sdk(ResourceType.MGMT_STORAGE, 'models#EncryptionServices')
Пример #54
0
    'count',
    help=
    'The Boolean value of true or false to request a count of the matching resources included with the resources in the response, e.g. Categories?$count=true.',
    type=bool)

# account params
register_cli_argument('dla',
                      'account_name',
                      datalake_analytics_name_type,
                      options_list=('--account', '-n'))
register_cli_argument('dla account', 'tags', tags_type)
register_cli_argument(
    'dla account',
    'tier',
    help='The desired commitment tier for this account to use.',
    **enum_choice_list(TierType))
register_cli_argument('dla account create',
                      'resource_group_name',
                      resource_group_name_type,
                      validator=None)
register_cli_argument('dla account create',
                      'account_name',
                      datalake_analytics_name_type,
                      options_list=('--account', '-n'),
                      completer=None)
register_cli_argument('dla account update',
                      'firewall_state',
                      help='Enable/disable existing firewall rules.',
                      **enum_choice_list(FirewallState))
register_cli_argument(
    'dla account update',
Пример #55
0
        webapp = parsed_args.webapp
        slot = getattr(parsed_args, 'slot', None)
        result = _generic_site_operation(rg, webapp,
                                         'get_site_host_name_bindings', slot)
        # workaround an api defect, that 'name' is '<webapp>/<hostname>'
        return [r.name.split('/', 1)[1] for r in result]


# 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), etc',
    **enum_choice_list([
        'F1', 'FREE', 'D1', 'SHARED', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1',
        'P2', 'P3'
    ]))
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
register_cli_argument('webapp', 'app_instance', ignore_type)
register_cli_argument('functionapp', 'app_instance', ignore_type)
Пример #56
0
                       id_part='name',
                       help='Name of the server.')
 register_cli_argument('{0} server'.format(command_group_name),
                       'administrator_login',
                       options_list=('--admin-user', '-u'))
 register_cli_argument('{0} server'.format(command_group_name),
                       'administrator_login_password',
                       options_list=('--admin-password', '-p'),
                       required=False,
                       help='The password of the administrator login.')
 register_cli_argument(
     '{0} server'.format(command_group_name),
     'ssl_enforcement',
     options_list=('--ssl-enforcement', ),
     help='Enable ssl enforcement or not when connect to server.',
     **enum_choice_list(['Enabled', 'Disabled']))
 register_cli_argument('{0} server'.format(command_group_name),
                       'tier',
                       options_list=('--performance-tier', ),
                       help='The performance tier of the server.',
                       **enum_choice_list(['Basic', 'Standard']))
 register_cli_argument('{0} server'.format(command_group_name),
                       'capacity',
                       options_list=('--compute-units', ),
                       type=int,
                       help='Number of compute units.')
 register_cli_argument(
     '{0} server'.format(command_group_name),
     'storage_mb',
     options_list=('--storage-size', ),
     type=int,
Пример #57
0
    type=int,
    help=
    '0-based logical unit number (LUN). Max value depends on the Virutal Machine size.'
)
register_cli_argument(
    'vm disk',
    'vhd',
    type=VirtualHardDisk,
    help=
    'virtual hard disk\'s uri. For example:https://mystorage.blob.core.windows.net/vhds/d1.vhd'
)
register_cli_argument('vm disk',
                      'caching',
                      help='Host caching policy',
                      default=CachingTypes.none.value,
                      **enum_choice_list(CachingTypes))

for item in ['attach-existing', 'attach-new', 'detach']:
    register_cli_argument('vm disk {}'.format(item),
                          'vm_name',
                          arg_type=existing_vm_name,
                          options_list=('--vm-name', ),
                          id_part=None)

register_cli_argument('vm availability-set',
                      'availability_set_name',
                      name_arg_type,
                      completer=get_resource_name_completion_list(
                          'Microsoft.Compute/availabilitySets'),
                      help='Name of the availability set')
Пример #58
0
    "provide deployment parameter values, either json string, or use '@<file path>' to load from a file"
)
register_cli_argument('group deployment',
                      'template_file',
                      completer=FilesCompleter(),
                      type=file_type,
                      help="a template file path in the file system")
register_cli_argument('group deployment',
                      'template_uri',
                      help='a uri to a remote template file')
register_cli_argument(
    'group deployment',
    'mode',
    help=
    'Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)',
    **enum_choice_list(DeploymentMode))
register_cli_argument(
    'group deployment create',
    'deployment_name',
    options_list=('--name', '-n'),
    required=False,
    validator=validate_deployment_name,
    help='The deployment name. Default to template file base name')
register_cli_argument('group deployment operation show',
                      'operation_ids',
                      nargs='+',
                      help='A list of operation ids to show')
register_cli_argument('group export', 'include_comments', action='store_true')
register_cli_argument('group export',
                      'include_parameter_default_value',
                      action='store_true')
Пример #59
0
from .custom import get_role_definition_name_completion_list
from ._validators import validate_group, validate_member_id, validate_cert, VARIANT_GROUP_ID_ARGS

register_cli_argument('ad app', 'app_id', help='application id')
register_cli_argument('ad app', 'application_object_id', options_list=('--object-id',))
register_cli_argument('ad app', 'display_name', help='the display name of the application')
register_cli_argument('ad app', 'homepage', help='the url where users can sign in and use your app.')
register_cli_argument('ad app', 'identifier', options_list=('--id',), help='identifier uri, application id, or object id')
register_cli_argument('ad app', 'identifier_uris', nargs='+', help='space separated unique URIs that Azure AD can use for this app.')
register_cli_argument('ad app', '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.')
register_cli_argument('ad app', '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")
register_cli_argument('ad app', '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")
register_cli_argument('ad app', 'available_to_other_tenants', action='store_true', help='the application can be used from any Azure AD tenants')
register_cli_argument('ad app', '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
register_cli_argument('ad app', 'key_type', default='AsymmetricX509Cert', help='the type of the key credentials associated with the application', **enum_choice_list(['AsymmetricX509Cert', 'Password', 'Symmetric']))
register_cli_argument('ad app', 'key_usage', default='Verify', help='the usage of the key credentials associated with the application.', **enum_choice_list(['Sign', 'Verify']))

name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

register_cli_argument('ad sp', 'identifier', options_list=('--id',), help='service principal name, or object id')
register_cli_argument('ad sp create', 'identifier', options_list=('--id',), help='identifier uri, application id, or object id of the associated application')
register_cli_argument('ad sp create-for-rbac', 'scopes', nargs='+')
register_cli_argument('ad sp create-for-rbac', 'role', completer=get_role_definition_name_completion_list)
register_cli_argument('ad sp create-for-rbac', 'skip_assignment', action='store_true', help='do not create default assignment')
register_cli_argument('ad sp create-for-rbac', 'expanded_view', action='store_true', help=argparse.SUPPRESS)

for item in ['create-for-rbac', 'reset-credentials']:
    register_cli_argument('ad sp {}'.format(item), 'name', name_arg_type)
    register_cli_argument('ad sp {}'.format(item), 'cert', arg_group='Credential', validator=validate_cert)
    register_cli_argument('ad sp {}'.format(item), 'password', options_list=('--password', '-p'), arg_group='Credential')