From 677ae529b65f3c7bca0f11edaf5e5072eb3fe5d7 Mon Sep 17 00:00:00 2001 From: yugangw-msft Date: Wed, 4 Mar 2020 22:48:31 -0800 Subject: [PATCH 1/2] [ACR] add 'private-link-resource show' command --- src/azure-cli/azure/cli/command_modules/acr/_help.py | 10 ++++++++++ .../azure/cli/command_modules/acr/commands.py | 3 +++ src/azure-cli/azure/cli/command_modules/acr/custom.py | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/acr/_help.py b/src/azure-cli/azure/cli/command_modules/acr/_help.py index f2151eaf10f..2359d7611c2 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acr/_help.py @@ -1175,6 +1175,16 @@ short-summary: Delete a private endpoint connection request for a container registry long-summary: To create a private endpoint connection use "az network private-endpoint create". For more information see https://aka.ms/acr/private-link """ + +helps['acr private-link-resource'] = """ +type: group +short-summary: Manage registry private link resources. +""" + +helps['acr private-link-resource show'] = """ +type: command +short-summary: Show the private link resources supported for a registry +""" # endregion # region encryption diff --git a/src/azure-cli/azure/cli/command_modules/acr/commands.py b/src/azure-cli/azure/cli/command_modules/acr/commands.py index 6c3326f0f41..71b651542ee 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/commands.py +++ b/src/azure-cli/azure/cli/command_modules/acr/commands.py @@ -307,6 +307,9 @@ def load_command_table(self, _): # pylint: disable=too-many-statements g.command('approve', 'approve') g.command('reject', 'reject') + with self.command_group('acr private-link-resource', acr_custom_util, is_preview=True) as g: + g.command('show', 'show_private_link_resource') + with self.command_group('acr identity', acr_custom_util, is_preview=True) as g: g.command('show', 'show_identity') g.command('assign', 'assign_identity') diff --git a/src/azure-cli/azure/cli/command_modules/acr/custom.py b/src/azure-cli/azure/cli/command_modules/acr/custom.py index 97f55b7a669..2d71c8d91ce 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acr/custom.py @@ -493,3 +493,8 @@ def _resolve_identity_client_id(cli_ctx, managed_identity_resource_id): res = parse_resource_id(managed_identity_resource_id) client = get_mgmt_service_client(cli_ctx, ManagedServiceIdentityClient, subscription_id=res['subscription']) return client.user_assigned_identities.get(res['resource_group'], res['name']).client_id + + +def show_private_link_resource(cmd, client, registry_name, resource_group_name=None): + resource_group_name = get_resource_group_name_by_registry_name(cmd.cli_ctx, registry_name, resource_group_name) + return client.list_private_link_resources(resource_group_name, registry_name) From 356034a41978729808c027441010d4424c76b0f0 Mon Sep 17 00:00:00 2001 From: yugangw-msft Date: Wed, 4 Mar 2020 22:52:24 -0800 Subject: [PATCH 2/2] change to list --- src/azure-cli/azure/cli/command_modules/acr/_help.py | 4 ++-- src/azure-cli/azure/cli/command_modules/acr/commands.py | 2 +- src/azure-cli/azure/cli/command_modules/acr/custom.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acr/_help.py b/src/azure-cli/azure/cli/command_modules/acr/_help.py index 2359d7611c2..04a69b185da 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acr/_help.py @@ -1181,9 +1181,9 @@ short-summary: Manage registry private link resources. """ -helps['acr private-link-resource show'] = """ +helps['acr private-link-resource list'] = """ type: command -short-summary: Show the private link resources supported for a registry +short-summary: list the private link resources supported for a registry """ # endregion diff --git a/src/azure-cli/azure/cli/command_modules/acr/commands.py b/src/azure-cli/azure/cli/command_modules/acr/commands.py index 71b651542ee..7f8402ac992 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/commands.py +++ b/src/azure-cli/azure/cli/command_modules/acr/commands.py @@ -308,7 +308,7 @@ def load_command_table(self, _): # pylint: disable=too-many-statements g.command('reject', 'reject') with self.command_group('acr private-link-resource', acr_custom_util, is_preview=True) as g: - g.command('show', 'show_private_link_resource') + g.command('list', 'list_private_link_resources') with self.command_group('acr identity', acr_custom_util, is_preview=True) as g: g.command('show', 'show_identity') diff --git a/src/azure-cli/azure/cli/command_modules/acr/custom.py b/src/azure-cli/azure/cli/command_modules/acr/custom.py index 2d71c8d91ce..04ccfd78bfd 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acr/custom.py @@ -495,6 +495,6 @@ def _resolve_identity_client_id(cli_ctx, managed_identity_resource_id): return client.user_assigned_identities.get(res['resource_group'], res['name']).client_id -def show_private_link_resource(cmd, client, registry_name, resource_group_name=None): +def list_private_link_resources(cmd, client, registry_name, resource_group_name=None): resource_group_name = get_resource_group_name_by_registry_name(cmd.cli_ctx, registry_name, resource_group_name) return client.list_private_link_resources(resource_group_name, registry_name)