Skip to content

Commit

Permalink
Support provisioningState filtering for az deployment list (Azure#12634)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoxing-ms authored Mar 27, 2020
1 parent 3f0d72d commit 957ef3d
Show file tree
Hide file tree
Showing 11 changed files with 2,468 additions and 1,342 deletions.
21 changes: 21 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def load_arguments(self, _):
help="a template file path in the file system")
deployment_template_uri_type = CLIArgumentType(options_list=['--template-uri', '-u'], help='a uri to a remote template file')
deployment_parameters_type = CLIArgumentType(options_list=['--parameters', '-p'], action='append', nargs='+', completer=FilesCompleter(), help='the deployment parameters')
filter_type = CLIArgumentType(options_list=['--filter'], is_preview=True,
help='Filter expression using OData notation. You can use --filter "provisioningState eq \'{state}\'" to filter provisioningState. '
'To get more information, please visit https://docs.microsoft.com/en-us/rest/api/resources/deployments/listatsubscriptionscope#uri-parameters')

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

Expand Down Expand Up @@ -203,6 +206,9 @@ def load_arguments(self, _):
c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))

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

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

Expand All @@ -226,6 +232,9 @@ def load_arguments(self, _):
with self.argument_context('deployment operation') as c:
c.argument('operation_ids', nargs='+', help='A list of operation ids to show')

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

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

Expand All @@ -239,6 +248,9 @@ def load_arguments(self, _):
c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))

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

with self.argument_context('deployment group') as c:
c.argument('resource_group_name', arg_type=resource_group_name_type, completer=get_resource_group_completion_list, required=True)
c.argument('mode', arg_type=get_enum_type(DeploymentMode, default='incremental'), help='Incremental (only add resources to resource group) or Complete (remove extra resources from resource group)')
Expand All @@ -260,6 +272,9 @@ def load_arguments(self, _):
c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))

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

with self.argument_context('deployment mg') as c:
c.argument('management_group_id', arg_type=management_group_id_type)
c.argument('deployment_location', arg_type=get_location_type(self.cli_ctx), required=True)
Expand All @@ -274,6 +289,9 @@ def load_arguments(self, _):
c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))

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

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

Expand All @@ -290,6 +308,9 @@ def load_arguments(self, _):
c.argument('handle_extended_json_format', arg_type=extended_json_format_type,
deprecate_info=c.deprecate(target='--handle-extended-json-format/-j'))

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

with self.argument_context('group export') as c:
c.argument('include_comments', action='store_true')
c.argument('include_parameter_default_value', action='store_true')
Expand Down
16 changes: 8 additions & 8 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,24 +1069,24 @@ def list_applications(cmd, resource_group_name=None):
return list(applications)


def list_deployments_at_subscription_scope(cmd):
def list_deployments_at_subscription_scope(cmd, filter_string=None):
rcf = _resource_client_factory(cmd.cli_ctx)
return rcf.deployments.list_at_subscription_scope()
return rcf.deployments.list_at_subscription_scope(filter=filter_string)


def list_deployments_at_resource_group(cmd, resource_group_name):
def list_deployments_at_resource_group(cmd, resource_group_name, filter_string=None):
rcf = _resource_client_factory(cmd.cli_ctx)
return rcf.deployments.list_by_resource_group(resource_group_name)
return rcf.deployments.list_by_resource_group(resource_group_name, filter=filter_string)


def list_deployments_at_management_group(cmd, management_group_id):
def list_deployments_at_management_group(cmd, management_group_id, filter_string=None):
rcf = _resource_client_factory(cmd.cli_ctx)
return rcf.deployments.list_at_management_group_scope(management_group_id)
return rcf.deployments.list_at_management_group_scope(management_group_id, filter=filter_string)


def list_deployments_at_tenant_scope(cmd):
def list_deployments_at_tenant_scope(cmd, filter_string=None):
rcf = _resource_client_factory(cmd.cli_ctx)
return rcf.deployments.list_at_tenant_scope()
return rcf.deployments.list_at_tenant_scope(filter=filter_string)


def get_deployment_at_subscription_scope(cmd, deployment_name):
Expand Down
Loading

0 comments on commit 957ef3d

Please sign in to comment.