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

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

    with self.argument_context('monitor app-insights events show') as c:
        c.argument('event_type', options_list=['--type'], help='The type of events to retrieve.')
        c.argument('event', options_list=['--event'], help='GUID of the event to retrieve. This could be obtained by first listing and filtering events, then selecting an event of interest.')

    with self.argument_context('monitor app-insights query') as c:
        c.argument('application', validator=validate_applications, options_list=['--apps', '-a'], nargs='+', id_part='name', help='GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.')
        c.argument('analytics_query', help='Query to execute over Application Insights data.')
def load_arguments(self, _):
    with self.argument_context('monitor app-insights') as c:
        c.argument('application', options_list=['--app', '-a'], id_part='name', help='GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.')

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

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

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

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

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

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

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

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

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

    with self.argument_context('cosmosdb') as c:
        c.argument('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')
        c.argument('database_id',
                   options_list=['--db-name', '-d'],
                   help='Database Name')

    with self.argument_context('cosmosdb create') as c:
        c.argument('account_name', completer=None)
        c.argument('key_uri', help="The URI of the key vault", is_preview=True)
        c.argument('enable_free_tier',
                   arg_type=get_three_state_flag(),
                   help="If enabled the account is free-tier.",
                   is_preview=True)
        c.argument('server_version',
                   arg_type=get_enum_type(ServerVersion),
                   help="Valid only for MongoDB accounts.",
                   is_preview=True)
        c.argument('is_restore_request',
                   options_list=['--is-restore-request', '-r'],
                   arg_type=get_three_state_flag(),
                   help="Restore from an existing/deleted account.",
                   is_preview=True,
                   arg_group='Restore')
        c.argument(
            'restore_source',
            help=
            "The restorable-database-account Id of the source account from which the account has to be restored. Required if --is-restore-request is set to true.",
            is_preview=True,
            arg_group='Restore')
        c.argument(
            'restore_timestamp',
            arg_type=get_datetime_type(
                help=
                "The timestamp to which the account has to be restored to. Required if --is-restore-request is set to true."
            ),
            is_preview=True,
            arg_group='Restore')
        c.argument('databases_to_restore',
                   nargs='+',
                   action=CreateDatabaseRestoreResource,
                   is_preview=True,
                   arg_group='Restore')
        c.argument('backup_policy_type',
                   arg_type=get_enum_type(BackupPolicyTypes),
                   help="The type of backup policy of the account to create",
                   arg_group='Backup Policy')

    for scope in ['cosmosdb create', 'cosmosdb update']:
        with self.argument_context(scope) as c:
            c.ignore('resource_group_location')
            c.argument('locations', nargs='+', action=CreateLocation)
            c.argument('tags', arg_type=tags_type)
            c.argument(
                'default_consistency_level',
                arg_type=get_enum_type(DefaultConsistencyLevel),
                help=
                "default consistency level of the Cosmos DB database account")
            c.argument(
                'max_staleness_prefix',
                type=int,
                help=
                "when used with Bounded Staleness consistency, this value represents the number of stale requests tolerated. Accepted range for this value is 1 - 2,147,483,647"
            )
            c.argument(
                'max_interval',
                type=int,
                help=
                "when used with Bounded Staleness consistency, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 1 - 100"
            )
            c.argument(
                'ip_range_filter',
                nargs='+',
                options_list=['--ip-range-filter'],
                validator=validate_ip_range_filter,
                help=
                "firewall support. Specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma-separated and must not contain any spaces"
            )
            c.argument('kind',
                       arg_type=get_enum_type(DatabaseAccountKind),
                       help='The type of Cosmos DB database account to create')
            c.argument(
                'enable_automatic_failover',
                arg_type=get_three_state_flag(),
                help=
                'Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account.'
            )
            c.argument(
                'capabilities',
                nargs='+',
                validator=validate_capabilities,
                help=
                'set custom capabilities on the Cosmos DB database account.')
            c.argument(
                'enable_virtual_network',
                arg_type=get_three_state_flag(),
                help='Enables virtual network on the Cosmos DB database account'
            )
            c.argument('virtual_network_rules',
                       nargs='+',
                       validator=validate_virtual_network_rules,
                       help='ACL\'s for virtual network')
            c.argument('enable_multiple_write_locations',
                       arg_type=get_three_state_flag(),
                       help="Enable Multiple Write Locations")
            c.argument(
                'disable_key_based_metadata_write_access',
                arg_type=get_three_state_flag(),
                help=
                "Disable write operations on metadata resources (databases, containers, throughput) via account keys"
            )
            c.argument(
                'enable_public_network',
                options_list=['--enable-public-network', '-e'],
                arg_type=get_three_state_flag(),
                help="Enable or disable public network access to server.")
            c.argument('enable_analytical_storage',
                       arg_type=get_three_state_flag(),
                       help="Flag to enable log storage on the account.",
                       is_preview=True)
            c.argument(
                'backup_interval',
                type=int,
                help=
                "the frequency(in minutes) with which backups are taken (only for accounts with periodic mode backups)",
                arg_group='Backup Policy')
            c.argument(
                'backup_retention',
                type=int,
                help=
                "the time(in hours) for which each backup is retained (only for accounts with periodic mode backups)",
                arg_group='Backup Policy')

    with self.argument_context('cosmosdb restore') as c:
        c.argument(
            'target_database_account_name',
            options_list=['--target-database-account-name', '-n'],
            help=
            'Name of the new target Cosmos DB database account after the restore'
        )
        c.argument(
            'account_name',
            completer=None,
            options_list=['--account-name', '-a'],
            help=
            'Name of the source Cosmos DB database account for the restore',
            id_part=None)
        c.argument(
            'restore_timestamp',
            options_list=['--restore-timestamp', '-t'],
            arg_type=get_datetime_type(
                help="The timestamp to which the account has to be restored to."
            ))
        c.argument(
            'location',
            arg_type=get_location_type(self.cli_ctx),
            help=
            "The location of the source account from which restore is triggered. This will also be the write region of the restored account"
        )
        c.argument('databases_to_restore',
                   nargs='+',
                   action=CreateDatabaseRestoreResource)

    # Restorable Database Accounts
    with self.argument_context('cosmosdb restorable-database-account') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Location",
                   required=False)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=False)

    # Restorable Sql Databases
    with self.argument_context('cosmosdb sql restorable-database') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Location",
                   required=True)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=True)

    # Restorable Sql Containers
    with self.argument_context('cosmosdb sql restorable-container') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Location",
                   required=True)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=True)
        c.argument('restorable_sql_database_rid',
                   options_list=['--database-rid', '-d'],
                   help="Rid of the database",
                   required=True)

    # Restorable Sql Resources
    with self.argument_context('cosmosdb sql restorable-resource') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Azure Location of the account",
                   required=True)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=True)
        c.argument('restore_location',
                   options_list=['--restore-location', '-r'],
                   help="The region of the restore.",
                   required=True)
        c.argument('restore_timestamp_in_utc',
                   options_list=['--restore-timestamp', '-t'],
                   help="The timestamp of the restore",
                   required=True)

    # Restorable Mongodb Databases
    with self.argument_context('cosmosdb mongodb restorable-database') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Location",
                   required=True)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=True)

    # Restorable Mongodb Collections
    with self.argument_context('cosmosdb mongodb restorable-collection') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Location",
                   required=True)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=True)
        c.argument('restorable_mongodb_database_rid',
                   options_list=['--database-rid', '-d'],
                   help="Rid of the database",
                   required=True)

    # Restorable mongodb Resources
    with self.argument_context('cosmosdb mongodb restorable-resource') as c:
        c.argument('location',
                   options_list=['--location', '-l'],
                   help="Azure Location of the account",
                   required=True)
        c.argument('instance_id',
                   options_list=['--instance-id', '-i'],
                   help="InstanceId of the Account",
                   required=True)
        c.argument('restore_location',
                   options_list=['--restore-location', '-r'],
                   help="The region of the restore.",
                   required=True)
        c.argument('restore_timestamp_in_utc',
                   options_list=['--restore-timestamp', '-t'],
                   help="The timestamp of the restore",
                   required=True)
Beispiel #4
0
def load_arguments(self, _):
    from azure.mgmt.monitor.models import ConditionOperator, TimeAggregationOperator, EventData
    from .grammar.metric_alert.MetricAlertConditionValidator import dim_op_conversion, agg_conversion, op_conversion, sens_conversion
    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    webhook_prop_type = CLIArgumentType(validator=process_webhook_prop, nargs='*')

    autoscale_name_type = CLIArgumentType(options_list=['--autoscale-name'], help='Name of the autoscale settings.', id_part='name')
    autoscale_profile_name_type = CLIArgumentType(options_list=['--profile-name'], help='Name of the autoscale profile.')
    autoscale_rule_name_type = CLIArgumentType(options_list=['--rule-name'], help='Name of the autoscale rule.')
    scope_name_type = CLIArgumentType(help='Name of the Azure Monitor Private Link Scope.')

    with self.argument_context('monitor') as c:
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)

    # region Alerts
    with self.argument_context('monitor alert') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')

    with self.argument_context('monitor alert create') as c:
        c.resource_parameter('target', arg_group='Target Resource', alias='target', preserve_resource_group_parameter=True)
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('condition', action=ConditionAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Action') as c:
        c.argument('custom_emails', nargs='+')
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('actions', options_list=['--action', '-a'], action=AlertAddAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Condition') as c:
        c.argument('metric_name')
        c.argument('operator', arg_type=get_enum_type(ConditionOperator))
        c.argument('threshold')
        c.argument('time_aggregation', arg_type=get_enum_type(TimeAggregationOperator))
        c.argument('window_size')

    with self.argument_context('monitor alert update') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.resource_parameter('target', arg_group='Target Resource', required=False, preserve_resource_group_parameter=True)

    with self.argument_context('monitor alert update', arg_group='Action') as c:
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('add_actions', options_list=['--add-action', '-a'], nargs='+', action=AlertAddAction)
        c.argument('remove_actions', options_list=['--remove-action', '-r'], nargs='+', action=AlertRemoveAction)

    with self.argument_context('monitor alert update', arg_group='Condition') as c:
        c.argument('condition', action=ConditionAction, nargs='+')
        c.argument('metric')
        c.argument('operator', arg_type=get_enum_type(get_operator_map().keys()))
        c.argument('threshold')
        c.argument('aggregation', arg_type=get_enum_type(get_aggregation_map().keys()))
        c.argument('period', type=get_period_type())

    for scope in ['monitor alert show-incident', 'monitor alert list-incidents']:
        with self.argument_context(scope) as c:
            c.argument('rule_name', options_list=['--rule-name'], id_part='name')
            c.argument('incident_name', name_arg_type, id_part='child_name_1')

    with self.argument_context('monitor alert list-incidents') as c:
        c.argument('rule_name', options_list=['--rule-name'], id_part=None)
    # endregion

    # region Metrics
    with self.argument_context('monitor metrics') as c:
        c.argument('metricnamespace', options_list=['--namespace'], help='Namespace to query metric definitions for.')

    with self.argument_context('monitor metrics list-definitions') as c:
        c.resource_parameter('resource_uri', arg_group='Target Resource')

    with self.argument_context('monitor metrics list') as c:
        from azure.mgmt.monitor.models import AggregationType
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('metadata', action='store_true')
        c.argument('dimension', nargs='*', validator=validate_metric_dimension)
        c.argument('aggregation', arg_type=get_enum_type(t for t in AggregationType if t.name != 'none'), nargs='*')
        c.argument('metrics', nargs='+')
        c.argument('orderby', help='Aggregation to use for sorting results and the direction of the sort. Only one order can be specificed. Examples: sum asc')
        c.argument('top', help='Max number of records to retrieve. Valid only if --filter used.')
        c.argument('filters', options_list='--filter')
        c.argument('metric_namespace', options_list='--namespace')

    with self.argument_context('monitor metrics list', arg_group='Time') as c:
        c.argument('start_time', arg_type=get_datetime_type(help='Start time of the query.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End time of the query. Defaults to the current time.'))
        c.argument('offset', type=get_period_type(as_timedelta=True))
        c.argument('interval', arg_group='Time', type=get_period_type())

    with self.argument_context('monitor metrics list-namespaces', arg_group='Time') as c:
        c.argument('start_time', arg_type=get_datetime_type(help='Start time of the query.'))
    # endregion

    # region MetricAlerts
    with self.argument_context('monitor metrics alert') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.argument('severity', type=int, help='Severity of the alert from 0 (critical) to 4 (verbose).')
        c.argument('window_size', type=get_period_type(), help='Time over which to aggregate metrics in "##h##m##s" format.')
        c.argument('evaluation_frequency', type=get_period_type(), help='Frequency with which to evaluate the rule in "##h##m##s" format.')
        c.argument('auto_mitigate', arg_type=get_three_state_flag(), help='Automatically resolve the alert.')
        c.argument('condition', options_list=['--condition'], action=MetricAlertConditionAction, nargs='+')
        c.argument('description', help='Free-text description of the rule.')
        c.argument('scopes', nargs='+', help='Space-separated list of scopes the rule applies to. '
                                             'The resources specified in this parameter must be of the same type and exist in the same location.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('enabled', arg_type=get_three_state_flag(), help='Whether the metric alert rule is enabled.')
        c.argument('target_resource_type', options_list=['--target-resource-type', '--type'],
                   help='The resource type of the target resource(s) in scopes. '
                        'This must be provided when scopes is resource group or subscription.')
        c.argument('target_resource_region', options_list=['--target-resource-region', '--region'],
                   help='The region of the target resource(s) in scopes. '
                        'This must be provided when scopes is resource group or subscription.')

    with self.argument_context('monitor metrics alert create', arg_group=None) as c:
        c.argument('actions', options_list=['--action', '-a'], action=MetricAlertAddAction, nargs='+', validator=get_action_group_validator('actions'))

    with self.argument_context('monitor metrics alert update', arg_group='Action') as c:
        c.argument('add_actions', options_list='--add-action', action=MetricAlertAddAction, nargs='+', validator=get_action_group_validator('add_actions'))
        c.argument('remove_actions', nargs='+', validator=get_action_group_id_validator('remove_actions'))

    with self.argument_context('monitor metrics alert update', arg_group='Condition') as c:
        c.argument('add_conditions', options_list='--add-condition', action=MetricAlertConditionAction, nargs='+')
        c.argument('remove_conditions', nargs='+')

    with self.argument_context('monitor metrics alert dimension create', arg_group=None) as c:
        c.argument('dimension_name', options_list=['--name', '-n'],
                   help='Name of the dimension.')
        c.argument('operator', options_list=['--operator', '--op'],
                   arg_type=get_enum_type(dim_op_conversion.values(), default=dim_op_conversion['includes']),
                   help="Dimension operator.")
        c.argument('value_list', options_list=['--value', '-v'], nargs='+',
                   help='The values to apply on the operation.')

    with self.argument_context('monitor metrics alert condition create', arg_group=None) as c:
        c.argument('condition_type', options_list=['--type', '-t'], arg_type=get_enum_type(['static', 'dynamic']),
                   help='Type of condition threshold.')
        c.argument('metric_name', options_list=['--metric'],
                   help='Name of metric.')
        c.argument('metric_namespace', options_list=['--namespace'],
                   help='Namespace of metric.')
        c.argument('dimension_list', options_list=['--dimension'], nargs='+',
                   help='Dimension created by \'az monitor metrics alert dimension create\'.')
        c.argument('aggregation', arg_type=get_enum_type(agg_conversion.values()),
                   help='Time aggregation.')
        c.argument('operator', options_list=['--operator', '--op'], arg_type=get_enum_type(op_conversion.values()),
                   help="Operator for static threshold can be 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan' or 'LessThanOrEqual'. "
                   "Operator for dynamic threshold can be 'GreaterThan', 'LessThan', 'GreaterOrLessThan'.")
        c.argument('threshold', type=float,
                   help='Static threshold value.')
        c.argument('alert_sensitivity', options_list=['--sensitivity'],
                   arg_type=get_enum_type(sens_conversion.values(), default='Medium'),
                   help="Alert sensitivity for dynamic threshold.")
        c.argument('number_of_evaluation_periods', options_list=['--num-periods'], type=int,
                   help='The number of evaluation periods for dynamic threshold. '
                        'Range: 1-6.')
        c.argument('min_failing_periods_to_alert', options_list=['--num-violations'], type=int,
                   help='The number of violations to trigger an dynamic alert. '
                        'Range: 1-6. It should be less than or equal to --num-periods.')
        c.argument('ignore_data_before', options_list=['--since'],
                   arg_type=get_datetime_type(
                       help='The date from which to start learning the metric historical data and calculate the dynamic thresholds.'))

    # endregion

    # region Autoscale
    with self.argument_context('monitor autoscale') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('autoscale_setting_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('profile_name', arg_type=autoscale_profile_name_type)
        c.argument('rule_name', arg_type=autoscale_rule_name_type)
        c.argument('enabled', arg_type=get_three_state_flag(), help='Autoscale settings enabled status.')

    with self.argument_context('monitor autoscale', arg_group='Notification') as c:
        c.argument('actions', options_list=['--action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('add_actions', options_list=['--add-action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('remove_actions', options_list=['--remove-action', '-r'], action=AutoscaleRemoveAction, nargs='+')
        c.argument('email_administrator', arg_type=get_three_state_flag(), help='Send email to subscription administrator on scaling.')
        c.argument('email_coadministrators', arg_type=get_three_state_flag(), help='Send email to subscription co-administrators on scaling.')

    with self.argument_context('monitor autoscale create') as c:
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create the autoscale settings in a disabled state.')

    with self.argument_context('monitor autoscale', arg_group='Instance Limit') as c:
        c.argument('count', type=int, help='The numer of instances to use. If used with --min/max-count, the default number of instances to use.')
        c.argument('min_count', type=int, help='The minimum number of instances.')
        c.argument('max_count', type=int, help='The maximum number of instances.')

    with self.argument_context('monitor autoscale profile') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('profile_name', arg_type=autoscale_profile_name_type, options_list=['--name', '-n'])
        c.argument('copy_rules', help='Name of an existing schedule from which to copy the scaling rules for the new schedule.')

    with self.argument_context('monitor autoscale profile list-timezones') as c:
        c.argument('search_query', options_list=['--search-query', '-q'], help='Query text to find.')
        c.argument('offset', help='Filter results based on UTC hour offset.', type=timezone_offset_type)

    with self.argument_context('monitor autoscale profile', arg_group='Schedule') as c:
        c.argument('timezone', type=timezone_name_type)
        c.argument('start', arg_type=get_datetime_type(help='Start time.', timezone=False))
        c.argument('end', arg_type=get_datetime_type(help='End time.', timezone=False))
        c.argument('recurrence', options_list=['--recurrence', '-r'], nargs='+', validator=validate_autoscale_recurrence)

    with self.argument_context('monitor autoscale rule') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('rule_name', arg_type=autoscale_rule_name_type, options_list=['--name', '-n'])
        c.argument('scale', help='The direction and amount to scale.', action=AutoscaleScaleAction, nargs='+')
        c.argument('condition', help='Condition on which to scale.', action=AutoscaleConditionAction, nargs='+')
        c.argument('timegrain', validator=validate_autoscale_timegrain, nargs='+')
        c.argument('cooldown', type=int, help='The number of minutes that must elapse before another scaling event can occur.')

    with self.argument_context('monitor autoscale rule delete') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to remove, or '*' to clear all rules.")

    with self.argument_context('monitor autoscale rule copy') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to copy, or '*' to copy all rules.")
        c.argument('source_profile', options_list=['--source-schedule'], help='Name of the profile to copy rules from.')
        c.argument('dest_profile', options_list=['--dest-schedule'], help='Name of the profile to copy rules to.')

    with self.argument_context('monitor autoscale rule create') as c:
        c.resource_parameter('source', arg_group='Source', required=False, preserve_resource_group_parameter=True)
    # endregion

    # region Autoscale (OLD)
    with self.argument_context('monitor autoscale-settings') as c:
        c.argument('name', options_list=['--azure-resource-name'])
        c.argument('autoscale_setting_name', options_list=['--name', '-n'])

    with self.argument_context('monitor autoscale-settings create') as c:
        c.argument('parameters', type=get_json_object, help='JSON encoded parameters configuration. Use @{file} to load from a file. Use az autoscale-settings get-parameters-template to export json template.')

    for scope in ['monitor autoscale-settings show', 'monitor autoscale-settings delete']:
        with self.argument_context(scope) as c:
            c.argument('autoscale_setting_name', id_part='name')

    #  https://github.com/Azure/azure-rest-api-specs/issues/1017
    with self.argument_context('monitor autoscale-settings list') as c:
        c.ignore('filter')
    # endregion

    # region Diagnostic
    with self.argument_context('monitor diagnostic-settings') as c:
        c.argument('name', options_list=('--name', '-n'))

    with self.argument_context('monitor diagnostic-settings show') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings delete') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings update') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings create') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource', skip_validator=True)
        c.argument('logs', type=get_json_object)
        c.argument('metrics', type=get_json_object)
        c.argument('export_to_resource_specific', arg_type=get_three_state_flag(),
                   help='Indicate that the export to LA must be done to a resource specific table, '
                        'a.k.a. dedicated or fixed schema table, '
                        'as opposed to the default dynamic schema table called AzureDiagnostics. '
                        'This argument is effective only when the argument --workspace is also given.')

    with self.argument_context('monitor diagnostic-settings categories list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings categories show') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings subscription') as c:
        import argparse
        c.argument('subscription_id', validator=process_subscription_id, help=argparse.SUPPRESS, required=False)
        c.argument('logs', type=get_json_object, help="JSON encoded list of logs settings. Use '@{file}' to load from a file.")
        c.argument('name', help='The name of the diagnostic setting.', options_list=['--name', '-n'])
        c.argument('event_hub_name', help='The name of the event hub. If none is specified, the default event hub will be selected.')
        c.argument('event_hub_auth_rule', help='The resource Id for the event hub authorization rule.')
        c.argument('workspace', help='The resource id of the log analytics workspace.')
        c.argument('storage_account', help='The resource id of the storage account to which you would like to send the Activity Log.')
        c.argument('service_bus_rule', help="The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format '{service bus resource ID}/authorizationrules/{key name}'.")
    # endregion

    # region LogProfiles
    with self.argument_context('monitor log-profiles') as c:
        c.argument('log_profile_name', options_list=['--name', '-n'])

    with self.argument_context('monitor log-profiles create') as c:
        c.argument('name', options_list=['--name', '-n'])
        c.argument('categories', nargs='+')
        c.argument('locations', nargs='+')
        c.argument('days', type=int, arg_group='Retention Policy')
        c.argument('enabled', arg_type=get_three_state_flag(), arg_group='Retention Policy')
    # endregion

    # region ActivityLog
    with self.argument_context('monitor activity-log list') as c:
        activity_log_props = [x['key'] for x in EventData()._attribute_map.values()]  # pylint: disable=protected-access
        c.argument('select', nargs='+', arg_type=get_enum_type(activity_log_props))
        c.argument('max_events', type=int)

    with self.argument_context('monitor activity-log list', arg_group='Time') as c:
        c.argument('start_time', arg_type=get_datetime_type(help='Start time of the query.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End time of the query. Defaults to the current time.'))
        c.argument('offset', type=get_period_type(as_timedelta=True))

    with self.argument_context('monitor activity-log list', arg_group='Filter') as c:
        c.argument('filters', deprecate_info=c.deprecate(target='--filters', hide=True, expiration='3.0.0'), help='OData filters. Will ignore other filter arguments.')
        c.argument('correlation_id')
        c.argument('resource_group', resource_group_name_type)
        c.argument('resource_id')
        c.argument('resource_provider', options_list=['--namespace', c.deprecate(target='--resource-provider', redirect='--namespace', hide=True, expiration='3.0.0')])
        c.argument('caller')
        c.argument('status')
    # endregion

    # region ActionGroup
    with self.argument_context('monitor action-group') as c:
        c.argument('action_group_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor action-group create') as c:
        from .actions import ActionGroupReceiverParameterAction
        c.extra('receivers', options_list=['--action', '-a'], nargs='+', arg_group='Actions', action=ActionGroupReceiverParameterAction)
        c.extra('short_name')
        c.extra('tags')
        c.ignore('action_group')

    with self.argument_context('monitor action-group update', arg_group='Actions') as c:
        c.extra('add_receivers', options_list=['--add-action', '-a'], nargs='+', action=ActionGroupReceiverParameterAction)
        c.extra('remove_receivers', options_list=['--remove-action', '-r'], nargs='+')
        c.ignore('action_group')

    with self.argument_context('monitor action-group enable-receiver') as c:
        c.argument('receiver_name', options_list=['--name', '-n'], help='The name of the receiver to resubscribe.')
        c.argument('action_group_name', options_list=['--action-group'], help='The name of the action group.')
    # endregion

    # region ActivityLog Alerts
    with self.argument_context('monitor activity-log alert') as c:
        c.argument('activity_log_alert_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor activity-log alert create') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('disable', action='store_true')
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('action_groups', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert update-condition') as c:
        c.argument('reset', action='store_true')
        c.argument('add_conditions', options_list=['--add-condition', '-a'], nargs='+')
        c.argument('remove_conditions', options_list=['--remove-condition', '-r'], nargs='+')

    with self.argument_context('monitor activity-log alert update') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('enabled', arg_type=get_three_state_flag())

    with self.argument_context('monitor activity-log alert action-group add') as c:
        c.argument('reset', action='store_true')
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert action-group remove') as c:
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')

    with self.argument_context('monitor activity-log alert scope add') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('reset', action='store_true')

    with self.argument_context('monitor activity-log alert scope remove') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
    # endregion

    # region Log Analytics Workspace
    with self.argument_context('monitor log-analytics workspace') as c:
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('workspace_name', options_list=['--workspace-name', '-n'], help="Name of the Log Analytics Workspace.")
        c.argument('sku', help="The supported value: PerGB2018, CapacityReservation.")
        c.argument('capacity_reservation_level', options_list=['--capacity-reservation-level', '--level'], help='The capacity reservation level for this workspace, when CapacityReservation sku is selected. The maximum value is 1000 and must be in multiples of 100. If you want to increase the limit, please contact [email protected].')
        c.argument('daily_quota_gb', options_list=['--quota'], help='The workspace daily quota for ingestion in gigabytes. The minimum value is 0.023 and default is -1 which means unlimited.')
        c.argument('retention_time', help="The workspace data retention in days.", type=int, default=30)
        from azure.mgmt.loganalytics.models import PublicNetworkAccessType
        c.argument('public_network_access_for_ingestion', options_list=['--ingestion-access'], help='The public network access type to access workspace ingestion.',
                   arg_type=get_enum_type(PublicNetworkAccessType))
        c.argument('public_network_access_for_query', options_list=['--query-access'], help='The public network access type to access workspace query.',
                   arg_type=get_enum_type(PublicNetworkAccessType))
        c.argument('force', options_list=['--force', '-f'], arg_type=get_three_state_flag())

    with self.argument_context('monitor log-analytics workspace pack') as c:
        c.argument('intelligence_pack_name', options_list=['--name', '-n'])
        c.argument('workspace_name', options_list='--workspace-name')

    with self.argument_context('monitor log-analytics workspace saved-search') as c:
        c.argument('saved_search_id', options_list=['--name', '-n'], help="Name of the saved search and it's unique in a given workspace.")
        c.argument('workspace_name', options_list='--workspace-name')
        c.argument('category', help='The category of the saved search. This helps the user to find a saved search faster.')
        c.argument('display_name', help='Display name of the saved search.')
        c.argument('saved_query', options_list=['--saved-query', '-q'], help='The query expression for the saved search.')
        c.argument('function_alias', options_list=['--func-alias', '--fa'],
                   help='Function Aliases are short names given to Saved Searches so they can be easily referenced in query. They are required for Computer Groups.')
        c.argument('function_parameters', options_list=['--func-param', '--fp'],
                   help="The optional function parameters if query serves as a function. "
                        "Value should be in the following format: 'param-name1:type1 = default_value1, param-name2:type2 = default_value2'. "
                        "For more examples and proper syntax please refer to "
                        "https://docs.microsoft.com/en-us/azure/kusto/query/functions/user-defined-functions.")
        c.argument('tags', tags_type)
    # endregion

    # region Log Analytics Workspace table
    with self.argument_context('monitor log-analytics workspace table') as c:
        c.argument('table_name', name_arg_type, help='Name of the table.')
        c.argument('workspace_name', options_list='--workspace-name')
        c.argument('retention_in_days', options_list='--retention-time', help='The data table data retention in days, between 30 and 730. Setting this property to null will default to the workspace', type=int, required=True)
    # endregion

    # region Log Analytics Workspace Data Export
    with self.argument_context('monitor log-analytics workspace data-export') as c:
        c.argument('data_export_name', options_list=['--name', '-n'], help="Name of the data export rule")
        c.argument('workspace_name', options_list='--workspace-name')
        c.argument('table_names', nargs='+', options_list=['--tables', '-t'],
                   help='An array of tables to export.')
        c.argument('destination', validator=process_workspace_data_export_destination,
                   help='The destination resource ID. It should be a storage account, an event hub namespace or an event hub. '
                        'If event hub namespace is provided, event hub would be created for each table automatically.')
        c.ignore('data_export_type')
        c.ignore('event_hub_name')
        c.argument('enable', arg_type=get_three_state_flag(), help='Enable this data export rule.')
    # endregion

    # region Log Analytics Workspace Linked Service
    with self.argument_context('monitor log-analytics workspace linked-service') as c:
        c.argument('linked_service_name', name_arg_type, help='Name of the linkedServices resource. Supported values: cluster, automation.')
        c.argument('workspace_name', options_list='--workspace-name')
        c.argument('resource_id', help='The resource id of the resource that will be linked to the workspace. This '
                                       'should be used for linking resources which require read access.')
        c.argument('write_access_resource_id', help='The resource id of the resource that will be linked to the '
                                                    'workspace. This should be used for linking resources which '
                                                    'require write access.')
    # endregion

    # region Log Analytics Cluster
    with self.argument_context('monitor log-analytics cluster') as c:
        c.argument('cluster_name', name_arg_type, help='The name of the Log Analytics cluster.')
        c.argument('sku_name', help="The name of the SKU. Currently only support 'CapacityReservation'")
        c.argument('sku_capacity', help='The capacity of the SKU. It must be in the range of 1000-2000 per day and must'
                                        ' be in multiples of 100. If you want to increase the limit, please contact'
                                        ' [email protected]. It can be decreased only after 31 days.')
        c.argument('identity_type', help='The identity type. Supported values: SystemAssigned')

    with self.argument_context('monitor log-analytics cluster update') as c:
        c.argument('key_vault_uri', help='The Key Vault uri which holds the key associated with the Log Analytics cluster.')
        c.argument('key_name', help='The name of the key associated with the Log Analytics cluster.')
        c.argument('key_version', help='The version of the key associated with the Log Analytics cluster.')
    # endregion

    # region Log Analytics Linked Storage Account
    with self.argument_context('monitor log-analytics workspace linked-storage') as c:
        from azure.mgmt.loganalytics.models import DataSourceType
        c.argument('data_source_type', help='Data source type for the linked storage account.',
                   options_list=['--type'], arg_type=get_enum_type(DataSourceType))
        c.argument('storage_account_ids', nargs='+', options_list=['--storage-accounts'],
                   help='List of Name or ID of Azure Storage Account.',
                   validator=validate_storage_accounts_name_or_id)
    # endregion

    # region monitor clone
    with self.argument_context('monitor clone') as c:
        c.argument('source_resource', help="Resource ID of the source resource.")
        c.argument('target_resource', help="Resource ID of the target resource.")
        c.argument('always_clone', action='store_true',
                   help="If this argument is applied, "
                        "all monitor settings would be cloned instead of expanding its scope.")
        c.argument('monitor_types', options_list=['--types', '-t'], arg_type=get_enum_type(['metricsAlert']),
                   nargs='+', help='List of types of monitor settings which would be cloned.', default=['metricsAlert'])

    # region Private Link Resources
    for item in ['create', 'update', 'show', 'delete', 'list']:
        with self.argument_context('monitor private-link-scope {}'.format(item)) as c:
            c.argument('scope_name', scope_name_type, options_list=['--name', '-n'])
    with self.argument_context('monitor private-link-scope create') as c:
        c.ignore('location')

    with self.argument_context('monitor private-link-scope scoped-resource') as c:
        c.argument('scope_name', scope_name_type)
        c.argument('resource_name', options_list=['--name', '-n'], help='Name of the assigned resource.')
        c.argument('linked_resource_id', options_list=['--linked-resource'], help='ARM resource ID of the linked resource. It should be one of log analytics workspace or application insights component.')

    with self.argument_context('monitor private-link-scope private-link-resource') as c:
        c.argument('scope_name', scope_name_type)
        c.argument('group_name', options_list=['--name', '-n'], help='Name of the private link resource.')

    with self.argument_context('monitor private-link-scope private-endpoint-connection') as c:
        c.argument('scope_name', scope_name_type)
        c.argument('private_endpoint_connection_name', options_list=['--name', '-n'],
                   help='The name of the private endpoint connection associated with the private link scope.')
    for item in ['approve', 'reject', 'show', 'delete']:
        with self.argument_context('monitor private-link-scope private-endpoint-connection {}'.format(item)) as c:
            c.argument('private_endpoint_connection_name', options_list=['--name', '-n'], required=False,
                       help='The name of the private endpoint connection associated with the private link scope.')
            c.extra('connection_id', options_list=['--id'],
                    help='The ID of the private endpoint connection associated with the private link scope. You can get '
                    'it using `az monitor private-link-scope show`.')
            c.argument('scope_name', help='Name of the Azure Monitor Private Link Scope.', required=False)
            c.argument('resource_group_name', help='The resource group name of specified private link scope.',
                       required=False)
            c.argument('description', help='Comments for {} operation.'.format(item))
Beispiel #5
0
def load_arguments(self, _):
    from azure.mgmt.monitor.models import ConditionOperator, TimeAggregationOperator, EventData

    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    webhook_prop_type = CLIArgumentType(validator=process_webhook_prop, nargs='*')

    autoscale_name_type = CLIArgumentType(options_list=['--autoscale-name'], help='Name of the autoscale settings.', id_part='name')
    autoscale_profile_name_type = CLIArgumentType(options_list=['--profile-name'], help='Name of the autoscale profile.')
    autoscale_rule_name_type = CLIArgumentType(options_list=['--rule-name'], help='Name of the autoscale rule.')

    with self.argument_context('monitor') as c:
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)

    # region Alerts
    with self.argument_context('monitor alert') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')

    with self.argument_context('monitor alert create') as c:
        c.resource_parameter('target', arg_group='Target Resource', alias='target', preserve_resource_group_parameter=True)
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('condition', action=ConditionAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Action') as c:
        c.argument('custom_emails', nargs='+')
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('actions', options_list=['--action', '-a'], action=AlertAddAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Condition') as c:
        c.argument('metric_name')
        c.argument('operator', arg_type=get_enum_type(ConditionOperator))
        c.argument('threshold')
        c.argument('time_aggregation', arg_type=get_enum_type(TimeAggregationOperator))
        c.argument('window_size')

    with self.argument_context('monitor alert update') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.resource_parameter('target', arg_group='Target Resource', required=False, preserve_resource_group_parameter=True)

    with self.argument_context('monitor alert update', arg_group='Action') as c:
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('add_actions', options_list=['--add-action', '-a'], nargs='+', action=AlertAddAction)
        c.argument('remove_actions', options_list=['--remove-action', '-r'], nargs='+', action=AlertRemoveAction)

    with self.argument_context('monitor alert update', arg_group='Condition') as c:
        c.argument('condition', action=ConditionAction, nargs='+')
        c.argument('metric')
        c.argument('operator', arg_type=get_enum_type(get_operator_map().keys()))
        c.argument('threshold')
        c.argument('aggregation', arg_type=get_enum_type(get_aggregation_map().keys()))
        c.argument('period', type=get_period_type())

    for scope in ['monitor alert show-incident', 'monitor alert list-incidents']:
        with self.argument_context(scope) as c:
            c.argument('rule_name', options_list=['--rule-name'], id_part='name')
            c.argument('incident_name', name_arg_type, id_part='child_name_1')

    with self.argument_context('monitor alert list-incidents') as c:
        c.argument('rule_name', options_list=['--rule-name'], id_part=None)
    # endregion

    # region Metrics
    with self.argument_context('monitor metrics') as c:
        c.argument('metricnamespace', options_list=['--namespace'], help='Namespace to query metric definitions for.')

    with self.argument_context('monitor metrics list-definitions') as c:
        c.resource_parameter('resource_uri', arg_group='Target Resource')

    with self.argument_context('monitor metrics list') as c:
        from azure.mgmt.monitor.models import AggregationType
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('metadata', action='store_true')
        c.argument('dimension', nargs='*', validator=validate_metric_dimension)
        c.argument('aggregation', arg_type=get_enum_type(t for t in AggregationType if t.name != 'none'), nargs='*')
        c.argument('metrics', nargs='+')
        c.argument('orderby', help='Aggregation to use for sorting results and the direction of the sort. Only one order can be specificed. Examples: sum asc')
        c.argument('top', help='Max number of records to retrieve. Valid only if --filter used.')
        c.argument('filters', options_list='--filter')
        c.argument('metric_namespace', options_list='--namespace')

    with self.argument_context('monitor metrics list', arg_group='Time') as c:
        c.argument('start_time', arg_type=get_datetime_type(help='Start time of the query.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End time of the query. Defaults to the current time.'))
        c.argument('offset', type=get_period_type(as_timedelta=True))
        c.argument('interval', arg_group='Time', type=get_period_type())
    # endregion

    # region MetricAlerts
    with self.argument_context('monitor metrics alert') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.argument('severity', type=int, help='Severity of the alert from 0 (low) to 4 (high).')
        c.argument('window_size', type=get_period_type(), help='Time over which to aggregate metrics in "##h##m##s" format.')
        c.argument('evaluation_frequency', type=get_period_type(), help='Frequency with which to evaluate the rule in "##h##m##s" format.')
        c.argument('auto_mitigate', arg_type=get_three_state_flag(), help='Automatically resolve the alert.')
        c.argument('condition', options_list=['--condition'], action=MetricAlertConditionAction, nargs='+')
        c.argument('description', help='Free-text description of the rule.')
        c.argument('scopes', nargs='+', help='Space-separated list of scopes the rule applies to.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('enabled', arg_type=get_three_state_flag(), help='Whether the metric alert rule is enabled.')

    with self.argument_context('monitor metrics alert create', arg_group=None) as c:
        c.argument('actions', options_list=['--action', '-a'], action=MetricAlertAddAction, nargs='+', validator=get_action_group_validator('actions'))

    with self.argument_context('monitor metrics alert update', arg_group='Action') as c:
        c.argument('add_actions', options_list='--add-action', action=MetricAlertAddAction, nargs='+', validator=get_action_group_validator('add_actions'))
        c.argument('remove_actions', nargs='+', validator=get_action_group_id_validator('remove_actions'))

    with self.argument_context('monitor metrics alert update', arg_group='Condition') as c:
        c.argument('add_conditions', options_list='--add-condition', action=MetricAlertConditionAction, nargs='+')
        c.argument('remove_conditions', nargs='+')
    # endregion

    # region Autoscale
    with self.argument_context('monitor autoscale') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('autoscale_setting_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('profile_name', arg_type=autoscale_profile_name_type)
        c.argument('rule_name', arg_type=autoscale_rule_name_type)
        c.argument('enabled', arg_type=get_three_state_flag(), help='Autoscale settings enabled status.')

    with self.argument_context('monitor autoscale', arg_group='Notification') as c:
        c.argument('actions', options_list=['--action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('add_actions', options_list=['--add-action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('remove_actions', options_list=['--remove-action', '-r'], action=AutoscaleRemoveAction, nargs='+')
        c.argument('email_administrator', arg_type=get_three_state_flag(), help='Send email to subscription administrator on scaling.')
        c.argument('email_coadministrators', arg_type=get_three_state_flag(), help='Send email to subscription co-administrators on scaling.')

    with self.argument_context('monitor autoscale create') as c:
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create the autoscale settings in a disabled state.')

    with self.argument_context('monitor autoscale', arg_group='Instance Limit') as c:
        c.argument('count', type=int, help='The numer of instances to use. If used with --min/max-count, the default number of instances to use.')
        c.argument('min_count', type=int, help='The minimum number of instances.')
        c.argument('max_count', type=int, help='The maximum number of instances.')

    with self.argument_context('monitor autoscale profile') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('profile_name', arg_type=autoscale_profile_name_type, options_list=['--name', '-n'])
        c.argument('copy_rules', help='Name of an existing schedule from which to copy the scaling rules for the new schedule.')

    with self.argument_context('monitor autoscale profile list-timezones') as c:
        c.argument('search_query', options_list=['--search-query', '-q'], help='Query text to find.')
        c.argument('offset', help='Filter results based on UTC hour offset.', type=timezone_offset_type)

    with self.argument_context('monitor autoscale profile', arg_group='Schedule') as c:
        c.argument('timezone', type=timezone_name_type)
        c.argument('start', arg_type=get_datetime_type(help='Start time.', timezone=False))
        c.argument('end', arg_type=get_datetime_type(help='End time.', timezone=False))
        c.argument('recurrence', options_list=['--recurrence', '-r'], nargs='+', validator=validate_autoscale_recurrence)

    with self.argument_context('monitor autoscale rule') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('rule_name', arg_type=autoscale_rule_name_type, options_list=['--name', '-n'])
        c.argument('scale', help='The direction and amount to scale.', action=AutoscaleScaleAction, nargs='+')
        c.argument('condition', help='Condition on which to scale.', action=AutoscaleConditionAction, nargs='+')
        c.argument('timegrain', validator=validate_autoscale_timegrain, nargs='+')
        c.argument('cooldown', type=int, help='The number of minutes that must elapse before another scaling event can occur.')

    with self.argument_context('monitor autoscale rule delete') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to remove, or '*' to clear all rules.")

    with self.argument_context('monitor autoscale rule copy') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to copy, or '*' to copy all rules.")
        c.argument('source_profile', options_list=['--source-schedule'], help='Name of the profile to copy rules from.')
        c.argument('dest_profile', options_list=['--dest-schedule'], help='Name of the profile to copy rules to.')

    with self.argument_context('monitor autoscale rule create') as c:
        c.resource_parameter('source', arg_group='Source', required=False, preserve_resource_group_parameter=True)
    # endregion

    # region Autoscale (OLD)
    with self.argument_context('monitor autoscale-settings') as c:
        c.argument('name', options_list=['--azure-resource-name'])
        c.argument('autoscale_setting_name', options_list=['--name', '-n'])

    with self.argument_context('monitor autoscale-settings create') as c:
        c.argument('parameters', type=get_json_object, help='JSON encoded parameters configuration. Use @{file} to load from a file. Use az autoscale-settings get-parameters-template to export json template.')

    for scope in ['monitor autoscale-settings show', 'monitor autoscale-settings delete']:
        with self.argument_context(scope) as c:
            c.argument('autoscale_setting_name', id_part='name')

    #  https://github.com/Azure/azure-rest-api-specs/issues/1017
    with self.argument_context('monitor autoscale-settings list') as c:
        c.ignore('filter')
    # endregion

    # region Diagnostic
    with self.argument_context('monitor diagnostic-settings') as c:
        c.argument('name', options_list=('--name', '-n'))

    with self.argument_context('monitor diagnostic-settings show') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings delete') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings update') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings create') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource', skip_validator=True)
        c.argument('logs', type=get_json_object)
        c.argument('metrics', type=get_json_object)

    with self.argument_context('monitor diagnostic-settings categories list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings categories show') as c:
        c.resource_parameter('resource_uri', required=True)
    # endregion

    # region LogProfiles
    with self.argument_context('monitor log-profiles') as c:
        c.argument('log_profile_name', options_list=['--name', '-n'])

    with self.argument_context('monitor log-profiles create') as c:
        c.argument('name', options_list=['--name', '-n'])
        c.argument('categories', nargs='+')
        c.argument('locations', nargs='+')
        c.argument('days', type=int, arg_group='Retention Policy')
        c.argument('enabled', arg_type=get_three_state_flag(), arg_group='Retention Policy')
    # endregion

    # region ActivityLog
    with self.argument_context('monitor activity-log list') as c:
        activity_log_props = [x['key'] for x in EventData()._attribute_map.values()]  # pylint: disable=protected-access
        c.argument('select', nargs='+', arg_type=get_enum_type(activity_log_props))
        c.argument('max_events', type=int)

    with self.argument_context('monitor activity-log list', arg_group='Time') as c:
        c.argument('start_time', arg_type=get_datetime_type(help='Start time of the query.'))
        c.argument('end_time', arg_type=get_datetime_type(help='End time of the query. Defaults to the current time.'))
        c.argument('offset', type=get_period_type(as_timedelta=True))

    with self.argument_context('monitor activity-log list', arg_group='Filter') as c:
        c.argument('filters', deprecate_info=c.deprecate(target='--filters', hide=True, expiration='2.1.0'), help='OData filters. Will ignore other filter arguments.')
        c.argument('correlation_id')
        c.argument('resource_group', resource_group_name_type)
        c.argument('resource_id')
        c.argument('resource_provider', options_list=['--namespace', c.deprecate(target='--resource-provider', redirect='--namespace', hide=True, expiration='2.1.0')])
        c.argument('caller')
        c.argument('status')
    # endregion

    # region ActionGroup
    with self.argument_context('monitor action-group') as c:
        c.argument('action_group_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor action-group create') as c:
        from .validators import process_action_group_detail_for_creation
        from .actions import ActionGroupReceiverParameterAction
        c.extra('receivers', options_list=['--action', '-a'], nargs='+', arg_group='Actions', action=ActionGroupReceiverParameterAction, validator=process_action_group_detail_for_creation)
        c.extra('short_name')
        c.extra('tags')
        c.ignore('action_group')

    with self.argument_context('monitor action-group update', arg_group='Actions') as c:
        c.extra('add_receivers', options_list=['--add-action', '-a'], nargs='+', action=ActionGroupReceiverParameterAction)
        c.extra('remove_receivers', options_list=['--remove-action', '-r'], nargs='+')
        c.ignore('action_group')

    with self.argument_context('monitor action-group enable-receiver') as c:
        c.argument('receiver_name', options_list=['--name', '-n'])
        c.argument('action_group_name', options_list=['--action-group'])
    # endregion

    # region ActivityLog Alerts
    with self.argument_context('monitor activity-log alert') as c:
        c.argument('activity_log_alert_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor activity-log alert create') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('disable', action='store_true')
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('action_groups', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert update-condition') as c:
        c.argument('reset', action='store_true')
        c.argument('add_conditions', options_list=['--add-condition', '-a'], nargs='+')
        c.argument('remove_conditions', options_list=['--remove-condition', '-r'], nargs='+')

    with self.argument_context('monitor activity-log alert update') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('enabled', arg_type=get_three_state_flag())

    with self.argument_context('monitor activity-log alert action-group add') as c:
        c.argument('reset', action='store_true')
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert action-group remove') as c:
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')

    with self.argument_context('monitor activity-log alert scope add') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('reset', action='store_true')

    with self.argument_context('monitor activity-log alert scope remove') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
def load_arguments(self, _):
    with self.argument_context('monitor app-insights') as c:
        c.argument('application', options_list=['--app', '-a'], id_part='name', help='GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.')

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

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

    with self.argument_context('monitor app-insights component') as c:
        c.argument('workspace_resource_id', options_list=['--workspace'], validator=validate_log_analytic_workspace_name_or_id,
                   help='Name or resource ID of a log analytics workspace')
        c.argument('retention_in_days', options_list=['--retention-time'], help='Retention in days for Application Insights. The value can be one of the following values: 30,60,90,120,180,270,365,550,730. It can be set only when Application Insights is not connected to a Log Analytics workspace.')
        from .vendored_sdks.mgmt_applicationinsights.models import PublicNetworkAccessType
        c.argument('public_network_access_for_ingestion', options_list=['--ingestion-access'], help='The public network access type for accessing Application Insights ingestion.',
                   arg_type=get_enum_type(PublicNetworkAccessType))
        c.argument('public_network_access_for_query', options_list=['--query-access'], help='The public network access type for accessing Application Insights query.',
                   arg_type=get_enum_type(PublicNetworkAccessType))

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

    with self.argument_context('monitor app-insights component connect-webapp') as c:
        c.argument('app_service', options_list=['--web-app'], help="Name or resource id of the web app.", validator=validate_app_service, id_part=None)
        c.argument('enable_profiler', help='Enable collecting profiling traces that help you see where time is spent in code. Currently it is only supported for .NET/.NET Core Web Apps.', arg_type=get_three_state_flag())
        c.argument('enable_snapshot_debugger', options_list=['--enable-snapshot-debugger', '--enable-debugger'], help='Enable snapshot debugger when an exception is thrown. Currently it is only supported for .NET/.NET Core Web Apps.', arg_type=get_three_state_flag())

    with self.argument_context('monitor app-insights component connect-function') as c:
        c.argument('app_service', options_list=['--function'], help="Name or resource id of the Azure function.", validator=validate_app_service)

    with self.argument_context('monitor app-insights component billing') as c:
        c.argument('stop_sending_notification_when_hitting_cap', options_list=['-s', '--stop'], arg_type=get_three_state_flag(),
                   help='Do not send a notification email when the daily data volume cap is met.')
        c.argument('cap', type=float, help='Daily data volume cap in GB.')

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

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

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

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

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

    with self.argument_context('monitor app-insights component linked-storage') as c:
        c.argument('storage_account_id', options_list=['--storage-account', '-s'], validator=validate_storage_account_name_or_id,
                   help='Name or ID of a linked storage account.')

    with self.argument_context('monitor app-insights component continues-export list') as c:
        c.argument('application', id_part=None)

    with self.argument_context('monitor app-insights component continues-export') as c:
        c.argument('record_types', nargs='+',
                   arg_type=get_enum_type(
                       ['Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd',
                        'PerformanceCounters', 'Availability', 'Messages']),
                   help='The document types to be exported, as comma separated values. Allowed values include \'Requests\', \'Event\', \'Exceptions\', \'Metrics\', \'PageViews\', \'PageViewPerformance\', \'Rdd\', \'PerformanceCounters\', \'Availability\', \'Messages\'.')
        c.argument('dest_sub_id', arg_group='Destination',
                   help='The subscription ID of the destination storage account.')
        c.argument('dest_account', validator=validate_dest_account, arg_group='Destination',
                   help='The name of destination storage account.')
        c.argument('dest_container', arg_group='Destination', help='The name of the destination storage container.')
        c.argument('dest_sas', arg_group='Destination',
                   help='The SAS token for the destination storage container. It must grant write permission.')
        c.argument('dest_type', arg_group='Destination', arg_type=get_enum_type(['Blob']),
                   help='The Continuous Export destination type. This has to be \'Blob\'.')
        c.argument('is_enabled', arg_type=get_three_state_flag(return_label=True),
                   help='Set to \'true\' to create a Continuous Export configuration as enabled, otherwise set it to \'false\'.')

    for scope in ['update', 'show', 'delete']:
        with self.argument_context('monitor app-insights component continues-export {}'.format(scope)) as c:
            c.argument('export_id', options_list=['--id'],
                       help='The Continuous Export configuration ID. This is unique within a Application Insights component.')
Beispiel #7
0
def load_arguments(self, _):
    from azure.mgmt.monitor.models import ConditionOperator, TimeAggregationOperator, EventData

    name_arg_type = CLIArgumentType(options_list=['--name', '-n'],
                                    metavar='NAME')
    webhook_prop_type = CLIArgumentType(validator=process_webhook_prop,
                                        nargs='*')

    autoscale_name_type = CLIArgumentType(
        options_list=['--autoscale-name'],
        help='Name of the autoscale settings.',
        id_part='name')
    autoscale_profile_name_type = CLIArgumentType(
        options_list=['--profile-name'], help='Name of the autoscale profile.')
    autoscale_rule_name_type = CLIArgumentType(
        options_list=['--rule-name'], help='Name of the autoscale rule.')
    scope_name_type = CLIArgumentType(
        help='Name of the Azure Monitor Private Link Scope.')

    with self.argument_context('monitor') as c:
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)

    # region Alerts
    with self.argument_context('monitor alert') as c:
        c.argument('rule_name',
                   name_arg_type,
                   id_part='name',
                   help='Name of the alert rule.')

    with self.argument_context('monitor alert create') as c:
        c.resource_parameter('target',
                             arg_group='Target Resource',
                             alias='target',
                             preserve_resource_group_parameter=True)
        c.argument('rule_name',
                   name_arg_type,
                   id_part='name',
                   help='Name of the alert rule.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('condition', action=ConditionAction, nargs='+')

    with self.argument_context('monitor alert create',
                               arg_group='Action') as c:
        c.argument('custom_emails', nargs='+')
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('actions',
                   options_list=['--action', '-a'],
                   action=AlertAddAction,
                   nargs='+')

    with self.argument_context('monitor alert create',
                               arg_group='Condition') as c:
        c.argument('metric_name')
        c.argument('operator', arg_type=get_enum_type(ConditionOperator))
        c.argument('threshold')
        c.argument('time_aggregation',
                   arg_type=get_enum_type(TimeAggregationOperator))
        c.argument('window_size')

    with self.argument_context('monitor alert update') as c:
        c.argument('rule_name',
                   name_arg_type,
                   id_part='name',
                   help='Name of the alert rule.')
        c.resource_parameter('target',
                             arg_group='Target Resource',
                             required=False,
                             preserve_resource_group_parameter=True)

    with self.argument_context('monitor alert update',
                               arg_group='Action') as c:
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('add_actions',
                   options_list=['--add-action', '-a'],
                   nargs='+',
                   action=AlertAddAction)
        c.argument('remove_actions',
                   options_list=['--remove-action', '-r'],
                   nargs='+',
                   action=AlertRemoveAction)

    with self.argument_context('monitor alert update',
                               arg_group='Condition') as c:
        c.argument('condition', action=ConditionAction, nargs='+')
        c.argument('metric')
        c.argument('operator',
                   arg_type=get_enum_type(get_operator_map().keys()))
        c.argument('threshold')
        c.argument('aggregation',
                   arg_type=get_enum_type(get_aggregation_map().keys()))
        c.argument('period', type=get_period_type())

    for scope in [
            'monitor alert show-incident', 'monitor alert list-incidents'
    ]:
        with self.argument_context(scope) as c:
            c.argument('rule_name',
                       options_list=['--rule-name'],
                       id_part='name')
            c.argument('incident_name', name_arg_type, id_part='child_name_1')

    with self.argument_context('monitor alert list-incidents') as c:
        c.argument('rule_name', options_list=['--rule-name'], id_part=None)
    # endregion

    # region Metrics
    with self.argument_context('monitor metrics') as c:
        c.argument('metricnamespace',
                   options_list=['--namespace'],
                   help='Namespace to query metric definitions for.')

    with self.argument_context('monitor metrics list-definitions') as c:
        c.resource_parameter('resource_uri', arg_group='Target Resource')

    with self.argument_context('monitor metrics list') as c:
        from azure.mgmt.monitor.models import AggregationType
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('metadata', action='store_true')
        c.argument('dimension', nargs='*', validator=validate_metric_dimension)
        c.argument('aggregation',
                   arg_type=get_enum_type(t for t in AggregationType
                                          if t.name != 'none'),
                   nargs='*')
        c.argument('metrics', nargs='+')
        c.argument(
            'orderby',
            help=
            'Aggregation to use for sorting results and the direction of the sort. Only one order can be specificed. Examples: sum asc'
        )
        c.argument(
            'top',
            help=
            'Max number of records to retrieve. Valid only if --filter used.')
        c.argument('filters', options_list='--filter')
        c.argument('metric_namespace', options_list='--namespace')

    with self.argument_context('monitor metrics list', arg_group='Time') as c:
        c.argument('start_time',
                   arg_type=get_datetime_type(help='Start time of the query.'))
        c.argument(
            'end_time',
            arg_type=get_datetime_type(
                help='End time of the query. Defaults to the current time.'))
        c.argument('offset', type=get_period_type(as_timedelta=True))
        c.argument('interval', arg_group='Time', type=get_period_type())
    # endregion

    # region MetricAlerts
    with self.argument_context('monitor metrics alert') as c:
        c.argument('rule_name',
                   name_arg_type,
                   id_part='name',
                   help='Name of the alert rule.')
        c.argument('severity',
                   type=int,
                   help='Severity of the alert from 0 (low) to 4 (high).')
        c.argument(
            'window_size',
            type=get_period_type(),
            help='Time over which to aggregate metrics in "##h##m##s" format.')
        c.argument(
            'evaluation_frequency',
            type=get_period_type(),
            help=
            'Frequency with which to evaluate the rule in "##h##m##s" format.')
        c.argument('auto_mitigate',
                   arg_type=get_three_state_flag(),
                   help='Automatically resolve the alert.')
        c.argument('condition',
                   options_list=['--condition'],
                   action=MetricAlertConditionAction,
                   nargs='+')
        c.argument('description', help='Free-text description of the rule.')
        c.argument('scopes',
                   nargs='+',
                   help='Space-separated list of scopes the rule applies to.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('enabled',
                   arg_type=get_three_state_flag(),
                   help='Whether the metric alert rule is enabled.')

    with self.argument_context('monitor metrics alert create',
                               arg_group=None) as c:
        c.argument('actions',
                   options_list=['--action', '-a'],
                   action=MetricAlertAddAction,
                   nargs='+',
                   validator=get_action_group_validator('actions'))

    with self.argument_context('monitor metrics alert update',
                               arg_group='Action') as c:
        c.argument('add_actions',
                   options_list='--add-action',
                   action=MetricAlertAddAction,
                   nargs='+',
                   validator=get_action_group_validator('add_actions'))
        c.argument('remove_actions',
                   nargs='+',
                   validator=get_action_group_id_validator('remove_actions'))

    with self.argument_context('monitor metrics alert update',
                               arg_group='Condition') as c:
        c.argument('add_conditions',
                   options_list='--add-condition',
                   action=MetricAlertConditionAction,
                   nargs='+')
        c.argument('remove_conditions', nargs='+')
    # endregion

    # region Autoscale
    with self.argument_context('monitor autoscale') as c:
        c.argument('autoscale_name',
                   arg_type=autoscale_name_type,
                   options_list=['--name', '-n'])
        c.argument('autoscale_setting_name',
                   arg_type=autoscale_name_type,
                   options_list=['--name', '-n'])
        c.argument('profile_name', arg_type=autoscale_profile_name_type)
        c.argument('rule_name', arg_type=autoscale_rule_name_type)
        c.argument('enabled',
                   arg_type=get_three_state_flag(),
                   help='Autoscale settings enabled status.')

    with self.argument_context('monitor autoscale',
                               arg_group='Notification') as c:
        c.argument('actions',
                   options_list=['--action', '-a'],
                   action=AutoscaleAddAction,
                   nargs='+')
        c.argument('add_actions',
                   options_list=['--add-action', '-a'],
                   action=AutoscaleAddAction,
                   nargs='+')
        c.argument('remove_actions',
                   options_list=['--remove-action', '-r'],
                   action=AutoscaleRemoveAction,
                   nargs='+')
        c.argument('email_administrator',
                   arg_type=get_three_state_flag(),
                   help='Send email to subscription administrator on scaling.')
        c.argument(
            'email_coadministrators',
            arg_type=get_three_state_flag(),
            help='Send email to subscription co-administrators on scaling.')

    with self.argument_context('monitor autoscale create') as c:
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('disabled',
                   arg_type=get_three_state_flag(),
                   help='Create the autoscale settings in a disabled state.')

    with self.argument_context('monitor autoscale',
                               arg_group='Instance Limit') as c:
        c.argument(
            'count',
            type=int,
            help=
            'The numer of instances to use. If used with --min/max-count, the default number of instances to use.'
        )
        c.argument('min_count',
                   type=int,
                   help='The minimum number of instances.')
        c.argument('max_count',
                   type=int,
                   help='The maximum number of instances.')

    with self.argument_context('monitor autoscale profile') as c:
        c.argument('autoscale_name',
                   arg_type=autoscale_name_type,
                   id_part=None)
        c.argument('profile_name',
                   arg_type=autoscale_profile_name_type,
                   options_list=['--name', '-n'])
        c.argument(
            'copy_rules',
            help=
            'Name of an existing schedule from which to copy the scaling rules for the new schedule.'
        )

    with self.argument_context(
            'monitor autoscale profile list-timezones') as c:
        c.argument('search_query',
                   options_list=['--search-query', '-q'],
                   help='Query text to find.')
        c.argument('offset',
                   help='Filter results based on UTC hour offset.',
                   type=timezone_offset_type)

    with self.argument_context('monitor autoscale profile',
                               arg_group='Schedule') as c:
        c.argument('timezone', type=timezone_name_type)
        c.argument('start',
                   arg_type=get_datetime_type(help='Start time.',
                                              timezone=False))
        c.argument('end',
                   arg_type=get_datetime_type(help='End time.',
                                              timezone=False))
        c.argument('recurrence',
                   options_list=['--recurrence', '-r'],
                   nargs='+',
                   validator=validate_autoscale_recurrence)

    with self.argument_context('monitor autoscale rule') as c:
        c.argument('autoscale_name',
                   arg_type=autoscale_name_type,
                   id_part=None)
        c.argument('rule_name',
                   arg_type=autoscale_rule_name_type,
                   options_list=['--name', '-n'])
        c.argument('scale',
                   help='The direction and amount to scale.',
                   action=AutoscaleScaleAction,
                   nargs='+')
        c.argument('condition',
                   help='Condition on which to scale.',
                   action=AutoscaleConditionAction,
                   nargs='+')
        c.argument('timegrain',
                   validator=validate_autoscale_timegrain,
                   nargs='+')
        c.argument(
            'cooldown',
            type=int,
            help=
            'The number of minutes that must elapse before another scaling event can occur.'
        )

    with self.argument_context('monitor autoscale rule delete') as c:
        c.argument(
            'index',
            nargs='+',
            help=
            "Space-separated list of rule indices to remove, or '*' to clear all rules."
        )

    with self.argument_context('monitor autoscale rule copy') as c:
        c.argument(
            'index',
            nargs='+',
            help=
            "Space-separated list of rule indices to copy, or '*' to copy all rules."
        )
        c.argument('source_profile',
                   options_list=['--source-schedule'],
                   help='Name of the profile to copy rules from.')
        c.argument('dest_profile',
                   options_list=['--dest-schedule'],
                   help='Name of the profile to copy rules to.')

    with self.argument_context('monitor autoscale rule create') as c:
        c.resource_parameter('source',
                             arg_group='Source',
                             required=False,
                             preserve_resource_group_parameter=True)
    # endregion

    # region Autoscale (OLD)
    with self.argument_context('monitor autoscale-settings') as c:
        c.argument('name', options_list=['--azure-resource-name'])
        c.argument('autoscale_setting_name', options_list=['--name', '-n'])

    with self.argument_context('monitor autoscale-settings create') as c:
        c.argument(
            'parameters',
            type=get_json_object,
            help=
            'JSON encoded parameters configuration. Use @{file} to load from a file. Use az autoscale-settings get-parameters-template to export json template.'
        )

    for scope in [
            'monitor autoscale-settings show',
            'monitor autoscale-settings delete'
    ]:
        with self.argument_context(scope) as c:
            c.argument('autoscale_setting_name', id_part='name')

    #  https://github.com/Azure/azure-rest-api-specs/issues/1017
    with self.argument_context('monitor autoscale-settings list') as c:
        c.ignore('filter')
    # endregion

    # region Diagnostic
    with self.argument_context('monitor diagnostic-settings') as c:
        c.argument('name', options_list=('--name', '-n'))

    with self.argument_context('monitor diagnostic-settings show') as c:
        c.resource_parameter('resource_uri',
                             required=True,
                             arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings delete') as c:
        c.resource_parameter('resource_uri',
                             required=True,
                             arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings update') as c:
        c.resource_parameter('resource_uri',
                             required=True,
                             arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings create') as c:
        c.resource_parameter('resource_uri',
                             required=True,
                             arg_group='Target Resource',
                             skip_validator=True)
        c.argument('logs', type=get_json_object)
        c.argument('metrics', type=get_json_object)

    with self.argument_context(
            'monitor diagnostic-settings categories list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context(
            'monitor diagnostic-settings categories show') as c:
        c.resource_parameter('resource_uri', required=True)
    # endregion

    # region LogProfiles
    with self.argument_context('monitor log-profiles') as c:
        c.argument('log_profile_name', options_list=['--name', '-n'])

    with self.argument_context('monitor log-profiles create') as c:
        c.argument('name', options_list=['--name', '-n'])
        c.argument('categories', nargs='+')
        c.argument('locations', nargs='+')
        c.argument('days', type=int, arg_group='Retention Policy')
        c.argument('enabled',
                   arg_type=get_three_state_flag(),
                   arg_group='Retention Policy')
    # endregion

    # region ActivityLog
    with self.argument_context('monitor activity-log list') as c:
        activity_log_props = [
            x['key'] for x in EventData()._attribute_map.values()
        ]  # pylint: disable=protected-access
        c.argument('select',
                   nargs='+',
                   arg_type=get_enum_type(activity_log_props))
        c.argument('max_events', type=int)

    with self.argument_context('monitor activity-log list',
                               arg_group='Time') as c:
        c.argument('start_time',
                   arg_type=get_datetime_type(help='Start time of the query.'))
        c.argument(
            'end_time',
            arg_type=get_datetime_type(
                help='End time of the query. Defaults to the current time.'))
        c.argument('offset', type=get_period_type(as_timedelta=True))

    with self.argument_context('monitor activity-log list',
                               arg_group='Filter') as c:
        c.argument('filters',
                   deprecate_info=c.deprecate(target='--filters',
                                              hide=True,
                                              expiration='3.0.0'),
                   help='OData filters. Will ignore other filter arguments.')
        c.argument('correlation_id')
        c.argument('resource_group', resource_group_name_type)
        c.argument('resource_id')
        c.argument('resource_provider',
                   options_list=[
                       '--namespace',
                       c.deprecate(target='--resource-provider',
                                   redirect='--namespace',
                                   hide=True,
                                   expiration='3.0.0')
                   ])
        c.argument('caller')
        c.argument('status')
    # endregion

    # region ActionGroup
    with self.argument_context('monitor action-group') as c:
        c.argument('action_group_name',
                   options_list=['--name', '-n'],
                   id_part='name')

    with self.argument_context('monitor action-group create') as c:
        from .validators import process_action_group_detail_for_creation
        from .actions import ActionGroupReceiverParameterAction
        c.extra('receivers',
                options_list=['--action', '-a'],
                nargs='+',
                arg_group='Actions',
                action=ActionGroupReceiverParameterAction,
                validator=process_action_group_detail_for_creation)
        c.extra('short_name')
        c.extra('tags')
        c.ignore('action_group')

    with self.argument_context('monitor action-group update',
                               arg_group='Actions') as c:
        c.extra('add_receivers',
                options_list=['--add-action', '-a'],
                nargs='+',
                action=ActionGroupReceiverParameterAction)
        c.extra('remove_receivers',
                options_list=['--remove-action', '-r'],
                nargs='+')
        c.ignore('action_group')

    with self.argument_context('monitor action-group enable-receiver') as c:
        c.argument('receiver_name', options_list=['--name', '-n'])
        c.argument('action_group_name', options_list=['--action-group'])
    # endregion

    # region ActivityLog Alerts
    with self.argument_context('monitor activity-log alert') as c:
        c.argument('activity_log_alert_name',
                   options_list=['--name', '-n'],
                   id_part='name')

    with self.argument_context('monitor activity-log alert create') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('disable', action='store_true')
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('condition',
                   options_list=['--condition', '-c'],
                   nargs='+',
                   validator=process_condition_parameter)
        c.argument('action_groups',
                   options_list=['--action-group', '-a'],
                   nargs='+')
        c.argument('webhook_properties',
                   options_list=['--webhook-properties', '-w'],
                   arg_type=webhook_prop_type)

    with self.argument_context(
            'monitor activity-log alert update-condition') as c:
        c.argument('reset', action='store_true')
        c.argument('add_conditions',
                   options_list=['--add-condition', '-a'],
                   nargs='+')
        c.argument('remove_conditions',
                   options_list=['--remove-condition', '-r'],
                   nargs='+')

    with self.argument_context('monitor activity-log alert update') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('condition',
                   options_list=['--condition', '-c'],
                   nargs='+',
                   validator=process_condition_parameter)
        c.argument('enabled', arg_type=get_three_state_flag())

    with self.argument_context(
            'monitor activity-log alert action-group add') as c:
        c.argument('reset', action='store_true')
        c.argument('action_group_ids',
                   options_list=['--action-group', '-a'],
                   nargs='+')
        c.argument('webhook_properties',
                   options_list=['--webhook-properties', '-w'],
                   arg_type=webhook_prop_type)

    with self.argument_context(
            'monitor activity-log alert action-group remove') as c:
        c.argument('action_group_ids',
                   options_list=['--action-group', '-a'],
                   nargs='+')

    with self.argument_context('monitor activity-log alert scope add') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('reset', action='store_true')

    with self.argument_context('monitor activity-log alert scope remove') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
    # endregion

    # region Log Analytics Workspace
    with self.argument_context('monitor log-analytics workspace') as c:
        c.argument('location',
                   get_location_type(self.cli_ctx),
                   validator=get_default_location_from_resource_group)
        c.argument('workspace_name',
                   options_list=['--workspace-name', '-n'],
                   help="Name of the Log Analytics Workspace.")
        c.ignore('sku')
        c.argument('retention_time',
                   help="The workspace data retention in days.",
                   type=int,
                   default=30)
        from azure.mgmt.loganalytics.models import PublicNetworkAccessType
        c.argument(
            'public_network_access_for_ingestion',
            options_list=['--ingestion-access'],
            help=
            'The public network access type to access workspace ingestion.',
            arg_type=get_enum_type(PublicNetworkAccessType))
        c.argument(
            'public_network_access_for_query',
            options_list=['--query-access'],
            help='The public network access type to access workspace query.',
            arg_type=get_enum_type(PublicNetworkAccessType))

    with self.argument_context('monitor log-analytics workspace pack') as c:
        c.argument('intelligence_pack_name', options_list=['--name', '-n'])
        c.argument('workspace_name', options_list='--workspace-name')
    # endregion

    # region Log Analytics Workspace Linked Service
    with self.argument_context(
            'monitor log-analytics workspace linked-service') as c:
        c.argument(
            'linked_service_name',
            name_arg_type,
            help=
            'Name of the linkedServices resource. Supported values: cluster, automation.'
        )
        c.argument('workspace_name', options_list='--workspace-name')
        c.argument(
            'resource_id',
            help=
            'The resource id of the resource that will be linked to the workspace. This '
            'should be used for linking resources which require read access.')
        c.argument(
            'write_access_resource_id',
            help='The resource id of the resource that will be linked to the '
            'workspace. This should be used for linking resources which '
            'require write access.')
    # endregion

    # region Log Analytics Cluster
    with self.argument_context('monitor log-analytics cluster') as c:
        c.argument('cluster_name',
                   name_arg_type,
                   help='The name of the Log Analytics cluster.')
        c.argument(
            'sku_name',
            help=
            "The name of the SKU. Currently only support 'CapacityReservation'"
        )
        c.argument(
            'sku_capacity',
            help=
            'The capacity of the SKU. It must be in the range of 1000-2000 per day and must'
            ' be in multiples of 100. If you want to increase the limit, please contact'
            ' [email protected]. It can be decreased only after 31 days.'
        )
        c.argument('identity_type',
                   help='The identity type. Supported values: SystemAssigned')

    with self.argument_context('monitor log-analytics cluster update') as c:
        c.argument(
            'key_vault_uri',
            help=
            'The Key Vault uri which holds the key associated with the Log Analytics cluster.'
        )
        c.argument(
            'key_name',
            help=
            'The name of the key associated with the Log Analytics cluster.')
        c.argument(
            'key_version',
            help=
            'The version of the key associated with the Log Analytics cluster.'
        )
    # endregion

    # region Log Analytics Linked Storage Account
    with self.argument_context(
            'monitor log-analytics workspace linked-storage') as c:
        from azure.mgmt.loganalytics.models import DataSourceType
        c.argument('data_source_type',
                   help='Data source type for the linked storage account.',
                   options_list=['--type'],
                   arg_type=get_enum_type(DataSourceType))
        c.argument('storage_account_ids',
                   nargs='+',
                   options_list=['--storage-accounts'],
                   help='List of Name or ID of Azure Storage Account.',
                   validator=validate_storage_accounts_name_or_id)
    # endregion

    # region monitor clone
    with self.argument_context('monitor clone') as c:
        c.argument('source_resource',
                   help="Resource ID of the source resource.")
        c.argument('target_resource',
                   help="Resource ID of the target resource.")
        c.argument(
            'always_clone',
            action='store_true',
            help="If this argument is applied, "
            "all monitor settings would be cloned instead of expanding its scope."
        )
        c.argument(
            'monitor_types',
            options_list=['--types', '-t'],
            arg_type=get_enum_type(['metricsAlert']),
            nargs='+',
            help='List of types of monitor settings which would be cloned.',
            default=['metricsAlert'])

    # region Private Link Resources
    for item in ['create', 'update', 'show', 'delete', 'list']:
        with self.argument_context(
                'monitor private-link-scope {}'.format(item)) as c:
            c.argument('scope_name',
                       scope_name_type,
                       options_list=['--name', '-n'])
    with self.argument_context('monitor private-link-scope create') as c:
        c.ignore('location')

    with self.argument_context(
            'monitor private-link-scope scoped-resource') as c:
        c.argument('scope_name', scope_name_type)
        c.argument('resource_name',
                   options_list=['--name', '-n'],
                   help='Name of the assigned resource.')
        c.argument(
            'linked_resource_id',
            options_list=['--linked-resource'],
            help=
            'ARM resource ID of the linked resource. It should be one of log analytics workspace or application insights component.'
        )

    with self.argument_context(
            'monitor private-link-scope private-link-resource') as c:
        c.argument('scope_name', scope_name_type)
        c.argument('group_name',
                   options_list=['--name', '-n'],
                   help='Name of the private link resource.')

    with self.argument_context(
            'monitor private-link-scope private-endpoint-connection') as c:
        c.argument('scope_name', scope_name_type)
        c.argument(
            'private_endpoint_connection_name',
            options_list=['--name', '-n'],
            help=
            'The name of the private endpoint connection associated with the private link scope.'
        )
    for item in ['approve', 'reject', 'show', 'delete']:
        with self.argument_context(
                'monitor private-link-scope private-endpoint-connection {}'.
                format(item)) as c:
            c.argument(
                'private_endpoint_connection_name',
                options_list=['--name', '-n'],
                required=False,
                help=
                'The name of the private endpoint connection associated with the private link scope.'
            )
            c.extra(
                'connection_id',
                options_list=['--id'],
                help=
                'The ID of the private endpoint connection associated with the private link scope. You can get '
                'it using `az monitor private-link-scope show`.')
            c.argument('scope_name',
                       help='Name of the Azure Monitor Private Link Scope.',
                       required=False)
            c.argument(
                'resource_group_name',
                help='The resource group name of specified private link scope.',
                required=False)
            c.argument('description',
                       help='Comments for {} operation.'.format(item))
Beispiel #8
0
def load_arguments(self, _):
    with self.argument_context('monitor app-insights') as c:
        c.argument('application', options_list=['--app', '-a'], id_part='name', help='GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.')

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

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

    with self.argument_context('monitor app-insights component') as c:
        c.argument('workspace_resource_id', options_list=['--workspace'], validator=validate_log_analytic_workspace_name_or_id,
                   help='Name or resource ID of a log analytics workspace')
        c.argument('retention_in_days', options_list=['--retention-time'], help='Retention in days for Application Insights. The value can be one of the following values: 30,60,90,120,180,270,365,550,730. It can be set only when Application Insights is not connected to a Log Analytics workspace.')
        from .vendored_sdks.mgmt_applicationinsights.models import PublicNetworkAccessType
        c.argument('public_network_access_for_ingestion', options_list=['--ingestion-access'], help='The public network access type for accessing Application Insights ingestion.',
                   arg_type=get_enum_type(PublicNetworkAccessType))
        c.argument('public_network_access_for_query', options_list=['--query-access'], help='The public network access type for accessing Application Insights query.',
                   arg_type=get_enum_type(PublicNetworkAccessType))

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

    with self.argument_context('monitor app-insights component connect-webapp') as c:
        c.argument('app_service', options_list=['--web-app'], help="Name or resource id of the web app.", validator=validate_app_service, id_part=None)
        c.argument('enable_profiler', help='Enable collecting profiling traces that help you see where time is spent in code. Currently it is only supported for .NET/.NET Core Web Apps.', arg_type=get_three_state_flag())
        c.argument('enable_snapshot_debugger', options_list=['--enable-snapshot-debugger', '--enable-debugger'], help='Enable snapshot debugger when an exception is thrown. Currently it is only supported for .NET/.NET Core Web Apps.', arg_type=get_three_state_flag())

    with self.argument_context('monitor app-insights component connect-function') as c:
        c.argument('app_service', options_list=['--function'], help="Name or resource id of the Azure function.", validator=validate_app_service)

    with self.argument_context('monitor app-insights component billing') as c:
        c.argument('stop_sending_notification_when_hitting_cap', options_list=['-s', '--stop'], arg_type=get_three_state_flag(),
                   help='Do not send a notification email when the daily data volume cap is met.')
        c.argument('cap', type=float, help='Daily data volume cap in GB.')

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

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

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

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

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

    with self.argument_context('monitor app-insights component linked-storage') as c:
        c.argument('storage_account_id', options_list=['--storage-account', '-s'], validator=validate_storage_account_name_or_id,
                   help='Name or ID of a linked storage account.')

    with self.argument_context('monitor app-insights component continues-export list') as c:
        c.argument('application', id_part=None)

    with self.argument_context('monitor app-insights component continues-export') as c:
        c.argument('record_types', nargs='+',
                   arg_type=get_enum_type(
                       ['Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd',
                        'PerformanceCounters', 'Availability', 'Messages']),
                   help='The document types to be exported, as comma separated values. Allowed values include \'Requests\', \'Event\', \'Exceptions\', \'Metrics\', \'PageViews\', \'PageViewPerformance\', \'Rdd\', \'PerformanceCounters\', \'Availability\', \'Messages\'.')
        c.argument('dest_sub_id', arg_group='Destination',
                   help='The subscription ID of the destination storage account.')
        c.argument('dest_account', validator=validate_dest_account, arg_group='Destination',
                   help='The name of destination storage account.')
        c.argument('dest_container', arg_group='Destination', help='The name of the destination storage container.')
        c.argument('dest_sas', arg_group='Destination',
                   help='The SAS token for the destination storage container. It must grant write permission.')
        c.argument('dest_type', arg_group='Destination', arg_type=get_enum_type(['Blob']),
                   help='The Continuous Export destination type. This has to be \'Blob\'.')
        c.argument('is_enabled', arg_type=get_three_state_flag(return_label=True),
                   help='Set to \'true\' to create a Continuous Export configuration as enabled, otherwise set it to \'false\'.')

    for scope in ['update', 'show', 'delete']:
        with self.argument_context(f'monitor app-insights component continues-export {scope}') as c:
            c.argument('export_id', options_list=['--id'],
                       help='The Continuous Export configuration ID. This is unique within a Application Insights component.')

    with self.argument_context('monitor app-insights web-test') as c:
        c.argument('web_test_name', options_list=['--name', '-n', '--web-test-name'], help='The name of the Application Insights WebTest resource.')
        c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False, validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)
        c.argument('kind', arg_type=get_enum_type(['ping', 'multistep']), help='The kind of WebTest that this web test watches. Choices are ping and multistep.')
        c.argument('synthetic_monitor_id', help='Unique ID of this WebTest. This is typically the same value as the Name field.')
        c.argument('web_test_properties_name_web_test_name', options_list=['--defined-web-test-name'], help='User defined name if this WebTest.')
        c.argument('description', help='User defined description for this WebTest.')
        c.argument('enabled', arg_type=get_three_state_flag(), help='Is the test actively being monitored.')
        c.argument('frequency', type=int, help='Interval in seconds between test runs for this WebTest. Default value is 300.')
        c.argument('timeout', type=int, help='Seconds until this WebTest will timeout and fail. Default value is 30.')
        c.argument('web_test_kind', arg_type=get_enum_type(['ping', 'multistep', 'standard']), help='The kind of web test this is, valid choices are ping, multistep and standard.')
        c.argument('retry_enabled', arg_type=get_three_state_flag(), help='Allow for retries should this WebTest fail.')
        c.argument('locations', action=AddLocations, nargs='+', help='A list of where to physically run the tests from to give global coverage for accessibility of your application.')

    with self.argument_context('monitor app-insights web-test', arg_group="Request") as c:
        c.argument('request_url', help='Url location to test.')
        c.argument('headers', action=AddHeaders, nargs='+', help='List of headers and their values to add to the WebTest call.')
        c.argument('http_verb', help='Http verb to use for this web test.')
        c.argument('request_body', help='Base64 encoded string body to send with this web test.')
        c.argument('parse_dependent_requests', options_list=['--parse-requests'], arg_type=get_three_state_flag(), help='Parse Dependent request for this WebTest.')
        c.argument('follow_redirects', arg_type=get_three_state_flag(), help='Follow redirects for this web test.')

    with self.argument_context('monitor app-insights web-test', arg_group="Validation Rules") as c:
        c.argument('content_validation', action=AddContentValidation, nargs='+', help='The collection of content validation properties')
        c.argument('ssl_check', arg_type=get_three_state_flag(), help='Checks to see if the SSL cert is still valid.')
        c.argument('ssl_cert_remaining_lifetime_check', options_list=['--ssl-lifetime-check'], type=int, help='A number of days to check still remain before the the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true.')
        c.argument('expected_http_status_code', options_list=['--expected-status-code'], type=int, help='Validate that the WebTest returns the http status code provided.')
        c.argument('ignore_https_status_code', options_list=['--ignore-status-code'], arg_type=get_three_state_flag(), help='When set, validation will ignore the status code.')

    with self.argument_context('monitor app-insights web-test', arg_group="Configuration") as c:
        c.argument('web_test', help='The XML specification of a WebTest to run against an application.')

    with self.argument_context('monitor app-insights web-test list') as c:
        c.argument('component_name', help='The name of the Application Insights component resource.')
Beispiel #9
0
def load_arguments(self, _):
    from azure.mgmt.monitor.models.monitor_management_client_enums import ConditionOperator, TimeAggregationOperator

    name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
    webhook_prop_type = CLIArgumentType(validator=process_webhook_prop, nargs='*')

    autoscale_name_type = CLIArgumentType(options_list=['--autoscale-name'], help='Name of the autoscale settings.', id_part='name')
    autoscale_profile_name_type = CLIArgumentType(options_list=['--profile-name'], help='Name of the autoscale profile.')
    autoscale_rule_name_type = CLIArgumentType(options_list=['--rule-name'], help='Name of the autoscale rule.')

    with self.argument_context('monitor') as c:
        c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('tags', tags_type)

    # region Alerts
    with self.argument_context('monitor alert') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')

    with self.argument_context('monitor alert create') as c:
        c.resource_parameter('target', arg_group='Target Resource', alias='target', preserve_resource_group_parameter=True)
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.argument('disabled', arg_type=get_three_state_flag())
        c.argument('condition', action=ConditionAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Action') as c:
        c.argument('custom_emails', nargs='+')
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('actions', options_list=['--action', '-a'], action=AlertAddAction, nargs='+')

    with self.argument_context('monitor alert create', arg_group='Condition') as c:
        c.argument('metric_name')
        c.argument('operator', arg_type=get_enum_type(ConditionOperator))
        c.argument('threshold')
        c.argument('time_aggregation', arg_type=get_enum_type(TimeAggregationOperator))
        c.argument('window_size')

    with self.argument_context('monitor alert update') as c:
        c.argument('rule_name', name_arg_type, id_part='name', help='Name of the alert rule.')
        c.resource_parameter('target', arg_group='Target Resource', required=False, preserve_resource_group_parameter=True)

    with self.argument_context('monitor alert update', arg_group='Action') as c:
        c.argument('email_service_owners', arg_type=get_three_state_flag())
        c.argument('add_actions', options_list=['--add-action', '-a'], nargs='+', action=AlertAddAction)
        c.argument('remove_actions', options_list=['--remove-action', '-r'], nargs='+', action=AlertRemoveAction)

    with self.argument_context('monitor alert update', arg_group='Condition') as c:
        c.argument('condition', action=ConditionAction, nargs='+')
        c.argument('metric')
        c.argument('operator', arg_type=get_enum_type(get_operator_map().keys()))
        c.argument('threshold')
        c.argument('aggregation', arg_type=get_enum_type(get_aggregation_map().keys()))
        c.argument('period', type=period_type)

    for scope in ['monitor alert show-incident', 'monitor alert list-incidents']:
        with self.argument_context(scope) as c:
            c.argument('rule_name', options_list=['--rule-name'], id_part='name')
            c.argument('incident_name', name_arg_type, id_part='child_name_1')

    with self.argument_context('monitor alert list-incidents') as c:
        c.argument('rule_name', options_list=['--rule-name'], id_part=None)
    # endregion

    # region Metrics
    with self.argument_context('monitor metrics') as c:
        c.argument('metricnamespace', options_list=['--namespace'], help='Namespace to query metric definitions for.')

    with self.argument_context('monitor metrics list-definitions') as c:
        c.resource_parameter('resource_uri', arg_group='Target Resource')

    with self.argument_context('monitor metrics list') as c:
        from .validators import (process_metric_timespan, process_metric_aggregation, process_metric_result_type,
                                 process_metric_dimension, validate_metric_names)
        from azure.mgmt.monitor.models.monitor_management_client_enums import AggregationType
        c.resource_parameter('resource_uri', arg_group='Target Resource')
        c.extra('start_time', options_list=['--start-time'], validator=process_metric_timespan, arg_group='Time')
        c.extra('end_time', options_list=['--end-time'], arg_group='Time')
        c.extra('metadata', options_list=['--metadata'], action='store_true', validator=process_metric_result_type)
        c.extra('dimension', options_list=['--dimension'], nargs='*', validator=process_metric_dimension)
        c.argument('interval', arg_group='Time')
        c.argument('aggregation', arg_type=get_enum_type(t for t in AggregationType if t.name != 'none'), nargs='*', validator=process_metric_aggregation)
        c.argument('metricnames', options_list=['--metrics'], nargs='+', help='Space-separated list of metric names to retrieve.', validator=validate_metric_names)
        c.ignore('timespan', 'result_type')
    # endregion

    # region Autoscale
    with self.argument_context('monitor autoscale') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('autoscale_setting_name', arg_type=autoscale_name_type, options_list=['--name', '-n'])
        c.argument('profile_name', arg_type=autoscale_profile_name_type)
        c.argument('rule_name', arg_type=autoscale_rule_name_type)
        c.argument('enabled', arg_type=get_three_state_flag(), help='Autoscale settings enabled status.')

    with self.argument_context('monitor autoscale', arg_group='Notification') as c:
        c.argument('actions', options_list=['--action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('add_actions', options_list=['--add-action', '-a'], action=AutoscaleAddAction, nargs='+')
        c.argument('remove_actions', options_list=['--remove-action', '-r'], action=AutoscaleRemoveAction, nargs='+')
        c.argument('email_administrator', arg_type=get_three_state_flag(), help='Send email to subscription administrator on scaling.')
        c.argument('email_coadministrators', arg_type=get_three_state_flag(), help='Send email to subscription co-administrators on scaling.')

    with self.argument_context('monitor autoscale create') as c:
        c.resource_parameter('resource', arg_group='Target Resource')
        c.argument('disabled', arg_type=get_three_state_flag(), help='Create the autoscale settings in a disabled state.')

    with self.argument_context('monitor autoscale', arg_group='Instance Limit') as c:
        c.argument('count', type=int, help='The numer of instances to use. If used with --min/max-count, the default number of instances to use.')
        c.argument('min_count', type=int, help='The minimum number of instances.')
        c.argument('max_count', type=int, help='The maximum number of instances.')

    with self.argument_context('monitor autoscale profile') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('profile_name', arg_type=autoscale_profile_name_type, options_list=['--name', '-n'])
        c.argument('copy_rules', help='Name of an existing schedule from which to copy the scaling rules for the new schedule.')

    with self.argument_context('monitor autoscale profile list-timezones') as c:
        c.argument('search_query', options_list=['--search-query', '-q'], help='Query text to find.')
        c.argument('offset', help='Filter results based on UTC hour offset.', type=timezone_offset_type)

    with self.argument_context('monitor autoscale profile', arg_group='Schedule') as c:
        c.argument('timezone', type=timezone_name_type)
        c.argument('start', arg_type=get_datetime_type(help='Start time.', timezone=False))
        c.argument('end', arg_type=get_datetime_type(help='End time.', timezone=False))
        c.argument('recurrence', options_list=['--recurrence', '-r'], nargs='+', validator=validate_autoscale_recurrence)

    with self.argument_context('monitor autoscale rule') as c:
        c.argument('autoscale_name', arg_type=autoscale_name_type, id_part=None)
        c.argument('rule_name', arg_type=autoscale_rule_name_type, options_list=['--name', '-n'])
        c.argument('scale', help='The direction and amount to scale.', action=AutoscaleScaleAction, nargs='+')
        c.argument('condition', help='Condition on which to scale.', action=AutoscaleConditionAction, nargs='+')
        c.argument('timegrain', validator=validate_autoscale_timegrain, nargs='+')
        c.argument('cooldown', type=int, help='The number of minutes that must elapse before another scaling event can occur.')

    with self.argument_context('monitor autoscale rule delete') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to remove, or '*' to clear all rules.")

    with self.argument_context('monitor autoscale rule copy') as c:
        c.argument('index', nargs='+', help="Space-separated list of rule indices to copy, or '*' to copy all rules.")
        c.argument('source_profile', options_list=['--source-schedule'], help='Name of the profile to copy rules from.')
        c.argument('dest_profile', options_list=['--dest-schedule'], help='Name of the profile to copy rules to.')

    with self.argument_context('monitor autoscale rule create') as c:
        c.resource_parameter('source', arg_group='Source', required=False, preserve_resource_group_parameter=True)
    # endregion

    # region Autoscale (OLD)
    with self.argument_context('monitor autoscale-settings') as c:
        c.argument('name', options_list=['--azure-resource-name'])
        c.argument('autoscale_setting_name', options_list=['--name', '-n'])

    with self.argument_context('monitor autoscale-settings create') as c:
        c.argument('parameters', type=get_json_object, help='JSON encoded parameters configuration. Use @{file} to load from a file. Use az autoscale-settings get-parameters-template to export json template.')

    for scope in ['monitor autoscale-settings show', 'monitor autoscale-settings delete']:
        with self.argument_context(scope) as c:
            c.argument('autoscale_setting_name', id_part='name')

    #  https://github.com/Azure/azure-rest-api-specs/issues/1017
    with self.argument_context('monitor autoscale-settings list') as c:
        c.ignore('filter')
    # endregion

    # region Diagnostic
    with self.argument_context('monitor diagnostic-settings') as c:
        c.argument('name', options_list=('--name', '-n'))

    with self.argument_context('monitor diagnostic-settings show') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings delete') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings update') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource')

    with self.argument_context('monitor diagnostic-settings create') as c:
        c.resource_parameter('resource_uri', required=True, arg_group='Target Resource', skip_validator=True)
        c.argument('logs', type=get_json_object)
        c.argument('metrics', type=get_json_object)

    with self.argument_context('monitor diagnostic-settings categories list') as c:
        c.resource_parameter('resource_uri', required=True)

    with self.argument_context('monitor diagnostic-settings categories show') as c:
        c.resource_parameter('resource_uri', required=True)
    # endregion

    # region LogProfiles
    with self.argument_context('monitor log-profiles') as c:
        c.argument('log_profile_name', options_list=['--name', '-n'])

    with self.argument_context('monitor log-profiles create') as c:
        c.argument('name', options_list=['--name', '-n'])
        c.argument('categories', nargs='+')
        c.argument('locations', nargs='+')
        c.argument('days', type=int, arg_group='Retention Policy')
        c.argument('enabled', arg_type=get_three_state_flag(), arg_group='Retention Policy')
    # endregion

    # region ActivityLog
    with self.argument_context('monitor activity-log list') as c:
        c.argument('select', nargs='+')

    with self.argument_context('monitor activity-log list', arg_group='OData Filter') as c:
        c.argument('correlation_id')
        c.argument('resource_group')
        c.argument('resource_id')
        c.argument('resource_provider')
        c.argument('start_time')
        c.argument('end_time')
        c.argument('caller')
        c.argument('status')
    # endregion

    # region ActionGroup
    with self.argument_context('monitor action-group') as c:
        c.argument('action_group_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor action-group create') as c:
        from .validators import process_action_group_detail_for_creation
        from .actions import ActionGroupReceiverParameterAction
        c.extra('receivers', options_list=['--action', '-a'], nargs='+', arg_group='Actions', action=ActionGroupReceiverParameterAction, validator=process_action_group_detail_for_creation)
        c.extra('short_name')
        c.extra('tags')
        c.ignore('action_group')

    with self.argument_context('monitor action-group update', arg_group='Actions') as c:
        c.extra('add_receivers', options_list=['--add-action', '-a'], nargs='+', action=ActionGroupReceiverParameterAction)
        c.extra('remove_receivers', options_list=['--remove-action', '-r'], nargs='+')
        c.ignore('action_group')

    with self.argument_context('monitor action-group enable-receiver') as c:
        c.argument('receiver_name', options_list=['--name', '-n'])
        c.argument('action_group_name', options_list=['--action-group'])
    # endregion

    # region ActivityLog Alerts
    with self.argument_context('monitor activity-log alert') as c:
        c.argument('activity_log_alert_name', options_list=['--name', '-n'], id_part='name')

    with self.argument_context('monitor activity-log alert create') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('disable', action='store_true')
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('action_groups', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert update-condition') as c:
        c.argument('reset', action='store_true')
        c.argument('add_conditions', options_list=['--add-condition', '-a'], nargs='+')
        c.argument('remove_conditions', options_list=['--remove-condition', '-r'], nargs='+')

    with self.argument_context('monitor activity-log alert update') as c:
        from .operations.activity_log_alerts import process_condition_parameter
        c.argument('condition', options_list=['--condition', '-c'], nargs='+', validator=process_condition_parameter)
        c.argument('enabled', arg_type=get_three_state_flag())

    with self.argument_context('monitor activity-log alert action-group add') as c:
        c.argument('reset', action='store_true')
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')
        c.argument('webhook_properties', options_list=['--webhook-properties', '-w'], arg_type=webhook_prop_type)

    with self.argument_context('monitor activity-log alert action-group remove') as c:
        c.argument('action_group_ids', options_list=['--action-group', '-a'], nargs='+')

    with self.argument_context('monitor activity-log alert scope add') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
        c.argument('reset', action='store_true')

    with self.argument_context('monitor activity-log alert scope remove') as c:
        c.argument('scopes', options_list=['--scope', '-s'], nargs='+')
Beispiel #10
0
def load_arguments(self, _):
    with self.argument_context('monitor app-insights') as c:
        c.argument(
            'application',
            options_list=['--app', '-a'],
            id_part='name',
            help=
            'GUID, app name, or fully-qualified Azure resource name of Application Insights component. The application GUID may be acquired from the API Access menu item on any Application Insights resource in the Azure portal. If using an application name, please specify resource group.'
        )

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

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

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

    with self.argument_context('monitor app-insights component billing') as c:
        c.argument(
            'stop_sending_notification_when_hitting_cap',
            options_list=['-s', '--stop'],
            arg_type=get_three_state_flag(),
            help=
            'Do not send a notification email when the daily data volume cap is met.'
        )
        c.argument('cap', type=int, help='Daily data volume cap in GB.')

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

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

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

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

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

    with self.argument_context('datashare account list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified

    with self.argument_context('datashare account show') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='The name of the share account.')  # modified

    with self.argument_context('datashare account create') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   options_list=['--name', '-n'],
                   help='The name of the share account.')  # modified
        c.argument(
            'location',
            arg_type=get_location_type(self.cli_ctx),
            validator=get_default_location_from_resource_group)  # modified
        c.argument('tags', tags_type)  # modified
        c.ignore(
            'identity'
        )  # Only system assigned identity is supported, we can omit this option

    with self.argument_context('datashare account update') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('tags', tags_type)  # modified

    with self.argument_context('datashare account delete') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='The name of the share account.')

    with self.argument_context('datashare account wait') as c:
        c.argument('account_name',
                   options_list=['--name', '-n'],
                   id_part='name',
                   help='The name of the share account.')  # modified

    with self.argument_context('datashare list') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')

    with self.argument_context('datashare show') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='The name of the share.')  # modified

    with self.argument_context('datashare create') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name',
                   options_list=['--name', '-n'],
                   help='The name of the share.')  # modified
        c.argument('description', help='Share description.')  # modified
        c.argument('share_kind',
                   arg_type=get_enum_type(ShareKind),
                   help='Share kind.')  # modified
        c.argument('terms', help='Share terms.')  # modified

    with self.argument_context('datashare delete') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='The name of the share.')  # modified

    with self.argument_context('datashare wait') as c:
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='The name of the share.')  # modified

    with self.argument_context('datashare dataset list') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')

    with self.argument_context('datashare dataset show') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('data_set_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the dataset.')  # modified

    with self.argument_context('datashare dataset create') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')
        c.argument('data_set_name',
                   options_list=['--name', '-n'],
                   help='The name of the dataset.')  # modified
        c.argument(
            'data_set',
            options_list=['--dataset'],
            type=validate_file_or_dict,
            help='Dataset parameters in JSON string or path to JSON file.'
        )  # modified

    with self.argument_context('datashare dataset delete') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('data_set_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the dataset.')  # modified

    with self.argument_context('datashare dataset wait') as c:
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('data_set_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the dataset.')  # modified

    with self.argument_context('datashare invitation list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')

    with self.argument_context('datashare invitation show') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('invitation_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the invitation.')  # modified

    with self.argument_context('datashare invitation create') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')
        c.argument('invitation_name',
                   options_list=['--name', '-n'],
                   help='The name of the invitation.')  # modified
        c.argument(
            'target_active_directory_id',
            help='The target Azure AD Id. Can\'t be combined with email.'
        )  # modified
        c.argument('target_email',
                   help='The email the invitation is directed to.')  # modified
        c.argument(
            'target_object_id',
            help=
            'The target user or application Id that invitation is being sent to. Must be specified along TargetActiveDirectoryId. This enables sending invitations to specific users or applications in an AD tenant.'
        )  # modified

    with self.argument_context('datashare invitation delete') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('invitation_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the invitation.')  # modified

    with self.argument_context('datashare synchronization-setting list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')

    with self.argument_context('datashare synchronization-setting show') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('synchronization_setting_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the synchronizationSetting.')  # modified

    with self.argument_context(
            'datashare synchronization-setting create') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')
        c.argument('synchronization_setting_name',
                   options_list=['--name', '-n'],
                   help='The name of the synchronizationSetting.')  # modified
        c.argument('recurrence_interval',
                   arg_type=get_enum_type(RecurrenceInterval),
                   arg_group='Synchronization Setting',
                   help='Synchronization Recurrence Interval.')
        c.argument('synchronization_time',
                   arg_group='Synchronization Setting',
                   arg_type=get_datetime_type(help='Synchronization time.'))
        c.argument('kind',
                   arg_type=get_enum_type(SynchronizationKind),
                   arg_group='Synchronization Setting',
                   default='ScheduleBased',
                   help='Kind of synchronization.')

    with self.argument_context(
            'datashare synchronization-setting delete') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('synchronization_setting_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the synchronizationSetting.')  # modified

    with self.argument_context('datashare synchronization-setting wait') as c:
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('synchronization_setting_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the synchronizationSetting.')  # modified

    with self.argument_context('datashare synchronization list-detail') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   help='The name of the share account.')  # modified
        c.argument('share_name', help='The name of the share.')  # modified
        c.argument('synchronization_id', help='The synchronization GUID.')

    with self.argument_context(
            'datashare synchronization list') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   help='The name of the share account.')  # modified
        c.argument('share_name', help='The name of the share.')  # modified

    with self.argument_context(
            'datashare provider-share-subscription list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_name', help='The name of the share.')

    with self.argument_context(
            'datashare provider-share-subscription show') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument(
            'provider_share_subscription_id',
            options_list=['--share-subscription'],
            id_part='child_name_2',
            help='To locate share subscription')  # modified TODO validator

    with self.argument_context(
            'datashare provider-share-subscription revoke') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('provider_share_subscription_id',
                   options_list=['--share-subscription'],
                   id_part='child_name_2',
                   help='To locate share subscription')  # modified

    with self.argument_context(
            'datashare provider-share-subscription reinstate') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('provider_share_subscription_id',
                   options_list=['--share-subscription'],
                   id_part='child_name_2',
                   help='To locate share subscription')  # modified

    with self.argument_context(
            'datashare provider-share-subscription wait') as c:
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_name',
                   id_part='child_name_1',
                   help='The name of the share.')  # modified
        c.argument('provider_share_subscription_id',
                   options_list=['--share-subscription'],
                   id_part='child_name_2',
                   help='To locate share subscription')  # modified

    with self.argument_context('datashare consumer invitation list') as c:
        pass

    with self.argument_context('datashare consumer invitation show') as c:
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx))  # modified
        c.argument('invitation_id',
                   validator=invitation_id_validator,
                   help='An invitation id')

    with self.argument_context('datashare consumer invitation reject') as c:
        c.argument('location',
                   arg_type=get_location_type(self.cli_ctx))  # modified
        c.argument('invitation_id',
                   validator=invitation_id_validator,
                   help='An invitation id')  # modified

    with self.argument_context(
            'datashare consumer share-subscription list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')

    with self.argument_context(
            'datashare consumer share-subscription show') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_subscription_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='The name of the share subscription.')  # modified

    with self.argument_context(
            'datashare consumer share-subscription create') as c:
        from azure.cli.core.commands.parameters import get_location_name_type, get_location_completion_list
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   options_list=['--name', '-n'],
                   help='The name of the share subscription.')  # modified
        c.argument('invitation_id',
                   validator=invitation_id_validator,
                   help='The invitation id.')  # modified
        c.argument('source_share_location',
                   type=get_location_name_type(self.cli_ctx),
                   help='Source share location.',
                   completer=get_location_completion_list)  # modified

    with self.argument_context(
            'datashare consumer share-subscription delete') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_subscription_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='The name of the share subscription.')  # modified

    with self.argument_context(
            'datashare consumer share-subscription list-source-share-synchronization-setting'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')

    with self.argument_context(
            'datashare consumer share-subscription list-source-dataset') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')

    with self.argument_context(
            'datashare consumer share-subscription wait') as c:
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')
        c.argument('share_subscription_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_1',
                   help='The name of the share subscription.')  # modified

    with self.argument_context(
            'datashare consumer share-subscription synchronization start'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')
        c.argument('synchronization_mode',
                   arg_type=get_enum_type(SynchronizationMode),
                   help='Synchronization mode')  # modified

    with self.argument_context(
            'datashare consumer share-subscription synchronization cancel'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')
        c.argument('synchronization_id', help='The synchronization GUID')

    with self.argument_context(
            'datashare consumer share-subscription synchronization wait') as c:
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')
        c.argument('synchronization_id', help='The synchronization GUID')

    with self.argument_context(
            'datashare consumer share-subscription synchronization list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')

    with self.argument_context(
            'datashare consumer share-subscription synchronization list-detail'
    ) as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')
        c.argument('synchronization_id', help='Synchronization id')

    with self.argument_context(
            'datashare consumer dataset-mapping list') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')

    with self.argument_context(
            'datashare consumer dataset-mapping show') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')
        c.argument('share_subscription_name',
                   id_part='child_name_1',
                   help='The name of the share subscription.')
        c.argument('data_set_mapping_name',
                   id_part='child_name_2',
                   options_list=['--name', '-n'],
                   help='The name of the datasetMapping.')  # modified

    with self.argument_context(
            'datashare consumer dataset-mapping create') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')
        c.argument('data_set_mapping_name',
                   options_list=['--name', '-n'],
                   help='The name of the datasetMapping.')  # modified
        c.argument('data_set_mapping',
                   options_list=['--mapping'],
                   type=validate_file_or_dict,
                   help='Dataset mapping in JSON string or path to JSON file.'
                   )  # modified

    with self.argument_context(
            'datashare consumer dataset-mapping delete') as c:  # modified
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')
        c.argument('share_subscription_name',
                   id_part='child_name_1',
                   help='The name of the share subscription.')
        c.argument('data_set_mapping_name',
                   id_part='child_name_2',
                   options_list=['--name', '-n'],
                   help='The name of the datasetMapping.')  # modified

    with self.argument_context('datashare consumer dataset-mapping wait') as c:
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')
        c.argument('share_subscription_name',
                   id_part='child_name_1',
                   help='The name of the share subscription.')
        c.argument('data_set_mapping_name',
                   id_part='child_name_2',
                   options_list=['--name', '-n'],
                   help='The name of the datasetMapping.')  # modified

    with self.argument_context('datashare consumer trigger list') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')

    with self.argument_context('datashare consumer trigger show') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')
        c.argument('share_subscription_name',
                   id_part='child_name_1',
                   help='The name of the share subscription.')
        c.argument('trigger_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the trigger.')

    with self.argument_context('datashare consumer trigger create') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name', help='The name of the share account.')
        c.argument('share_subscription_name',
                   help='The name of the share subscription.')
        c.argument('trigger_name',
                   options_list=['--name', '-n'],
                   help='The name of the trigger.')  # modified
        c.argument('recurrence_interval',
                   arg_type=get_enum_type(RecurrenceInterval),
                   arg_group='Synchronization Setting',
                   help='Synchronization Recurrence Interval.')
        c.argument('synchronization_time',
                   arg_group='Synchronization Setting',
                   arg_type=get_datetime_type(help='Synchronization time.'))
        c.argument('kind',
                   arg_type=get_enum_type(SynchronizationKind),
                   arg_group='Synchronization Setting',
                   default='ScheduleBased',
                   help='Kind of synchronization.')

    with self.argument_context('datashare consumer trigger delete') as c:
        c.argument('resource_group_name', resource_group_name_type)  # modified
        c.argument('account_name',
                   id_part='name',
                   help='The name of the share account.')  # modified
        c.argument('share_subscription_name',
                   id_part='child_name_1',
                   help='The name of the share subscription.')  # modified
        c.argument('trigger_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the trigger.')  # modified

    with self.argument_context('datashare consumer trigger wait') as c:
        c.argument('trigger_name',
                   options_list=['--name', '-n'],
                   id_part='child_name_2',
                   help='The name of the trigger.')  # modified