From 1f5cc247461c2865a9cc3a525823e00a3a6d1dfe Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Mon, 4 Apr 2022 10:07:16 -0700 Subject: [PATCH 1/9] remove mentions of access-policy --- .../azure/cli/command_modules/iot/_help.py | 50 ----------------- .../azure/cli/command_modules/iot/_params.py | 53 +++---------------- .../azure/cli/command_modules/iot/commands.py | 12 ----- .../test_iot_dps_commands.py | 10 ++-- 4 files changed, 13 insertions(+), 112 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_help.py b/src/azure-cli/azure/cli/command_modules/iot/_help.py index fbd581b8691..e712718514e 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_help.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_help.py @@ -18,56 +18,6 @@ short-summary: Manage Azure IoT Hub Device Provisioning Service. """ -helps['iot dps access-policy'] = """ -type: group -short-summary: Manage shared access policies for an Azure IoT Hub Device Provisioning Service instance. -""" - -helps['iot dps access-policy create'] = """ -type: command -short-summary: Create a new shared access policy in an Azure IoT Hub Device Provisioning Service instance. -examples: - - name: Create a new shared access policy in an Azure IoT Hub Device Provisioning Service instance with EnrollmentRead right - text: > - az iot dps access-policy create --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy --rights EnrollmentRead -""" - -helps['iot dps access-policy delete'] = """ -type: command -short-summary: Delete a shared access policies in an Azure IoT Hub Device Provisioning Service instance. -examples: - - name: Delete shared access policy 'MyPolicy' in the Azure IoT Hub Device Provisioning Service instance 'MyDps' - text: > - az iot dps access-policy delete --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy -""" - -helps['iot dps access-policy list'] = """ -type: command -short-summary: List all shared access policies in an Azure IoT Hub Device Provisioning Service instance. -examples: - - name: List all shared access policies in the Azure IoT Hub Device Provisioning Service instance 'MyDps' - text: > - az iot dps access-policy list --dps-name MyDps --resource-group MyResourceGroup -""" - -helps['iot dps access-policy show'] = """ -type: command -short-summary: Show details of a shared access policies in an Azure IoT Hub Device Provisioning Service instance. -examples: - - name: Show details of shared access policy 'MyPolicy' in the Azure IoT Hub Device Provisioning Service instance 'MyDps' - text: > - az iot dps access-policy show --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy -""" - -helps['iot dps access-policy update'] = """ -type: command -short-summary: Update a shared access policy in an Azure IoT Hub Device Provisioning Service instance. -examples: - - name: Update shared access policy 'MyPolicy' in an Azure IoT Hub Device Provisioning Service instance with EnrollmentWrite right - text: > - az iot dps access-policy update --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy --rights EnrollmentWrite -""" - helps['iot dps policy'] = """ type: group short-summary: Manage shared access policies for an Azure IoT Hub Device Provisioning Service instance. diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index 5965759ac4b..26faae83c37 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -78,55 +78,18 @@ def load_arguments(self, _): # pylint: disable=too-many-statements 'cross geo-pair disaster recovery. This property is immutable once set on the resource. ' 'Only available in select regions. Learn more at https://aka.ms/dpsdr') - # To deprecate - for subgroup in ['access-policy', 'linked-hub', 'certificate']: - with self.argument_context('iot dps {}'.format(subgroup)) as c: - c.argument('dps_name', options_list=['--dps-name'], id_part=None) - - # To replace deprecated - for subgroup in ['policy']: - with self.argument_context('iot dps {}'.format(subgroup)) as c: - c.argument('dps_name', options_list=['--dps-name', '-n'], id_part=None) - - with self.argument_context('iot dps access-policy') as c: - c.argument('access_policy_name', options_list=['--access-policy-name', '--name', '-n'], - help='A friendly name for DPS shared access policy.') - - with self.argument_context('iot dps access-policy create') as c: - c.argument('rights', options_list=['--rights', '-r'], nargs='+', - arg_type=get_enum_type(AccessRightsDescription), - help='Access rights for the IoT Hub Device Provisioning Service. ' - 'Use space-separated list for multiple rights.') - c.argument('primary_key', help='Primary SAS key value.') - c.argument('secondary_key', help='Secondary SAS key value.') - - with self.argument_context('iot dps access-policy update') as c: - c.argument('rights', options_list=['--rights', '-r'], nargs='+', - arg_type=get_enum_type(AccessRightsDescription), - help='Access rights for the IoT Hub Device Provisioning Service. ' - 'Use space-separated list for multiple rights.') - c.argument('primary_key', help='Primary SAS key value.') - c.argument('secondary_key', help='Secondary SAS key value.') - with self.argument_context('iot dps policy') as c: c.argument('access_policy_name', options_list=['--policy-name', '--pn'], help='A friendly name for DPS access policy.') - with self.argument_context('iot dps policy create') as c: - c.argument('rights', options_list=['--rights', '-r'], nargs='+', - arg_type=get_enum_type(AccessRightsDescription), - help='Access rights for the IoT Hub Device Provisioning Service. ' - 'Use space-separated list for multiple rights.') - c.argument('primary_key', help='Primary SAS key value.') - c.argument('secondary_key', help='Secondary SAS key value.') - - with self.argument_context('iot dps policy update') as c: - c.argument('rights', options_list=['--rights', '-r'], nargs='+', - arg_type=get_enum_type(AccessRightsDescription), - help='Access rights for the IoT Hub Device Provisioning Service. ' - 'Use space-separated list for multiple rights.') - c.argument('primary_key', help='Primary SAS key value.') - c.argument('secondary_key', help='Secondary SAS key value.') + for subgroup in ['create', 'update']: + with self.argument_context('iot dps policy {}'.format(subgroup)) as c: + c.argument('rights', options_list=['--rights', '-r'], nargs='+', + arg_type=get_enum_type(AccessRightsDescription), + help='Access rights for the IoT Hub Device Provisioning Service. ' + 'Use space-separated list for multiple rights.') + c.argument('primary_key', help='Primary SAS key value.') + c.argument('secondary_key', help='Secondary SAS key value.') with self.argument_context('iot dps linked-hub') as c: c.argument('linked_hub', options_list=['--linked-hub'], help='Host name of linked IoT Hub.') diff --git a/src/azure-cli/azure/cli/command_modules/iot/commands.py b/src/azure-cli/azure/cli/command_modules/iot/commands.py index e9544c7aa7b..7089046ed18 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/commands.py +++ b/src/azure-cli/azure/cli/command_modules/iot/commands.py @@ -60,18 +60,6 @@ def load_command_table(self, _): # pylint: disable=too-many-statements g.generic_update_command('update', getter_name='iot_dps_get', setter_name='iot_dps_update', command_type=update_custom_util) - # iot dps access-policy commands (Deprecated) - with self.command_group('iot dps access-policy', - client_factory=iot_service_provisioning_factory, - deprecate_info=self.deprecate(redirect='iot dps policy', - expiration='2.36.0') - ) as g: - g.custom_command('list', 'iot_dps_policy_list') - g.custom_show_command('show', 'iot_dps_policy_get') - g.custom_command('create', 'iot_dps_policy_create', supports_no_wait=True) - g.custom_command('update', 'iot_dps_policy_update', supports_no_wait=True) - g.custom_command('delete', 'iot_dps_policy_delete', supports_no_wait=True) - # iot dps linked-hub commands with self.command_group('iot dps linked-hub', client_factory=iot_service_provisioning_factory) as g: g.custom_command('list', 'iot_dps_linked_hub_list') diff --git a/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py b/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py index 806dce2a865..24fc72a0116 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py +++ b/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py @@ -58,33 +58,33 @@ def test_dps_lifecycle(self, group_name, group_location): new_right = 'EnrollmentWrite' # Create access policy - self.cmd('az iot dps access-policy create -g {} --dps-name {} -n {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ + self.cmd('az iot dps policy create -g {} --dps-name {} -n {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # List access policy - self.cmd('az iot dps access-policy list -g {} --dps-name {}'.format(group_name, dps_name), checks=[ + self.cmd('az iot dps policy list -g {} --dps-name {}'.format(group_name, dps_name), checks=[ self.check('length([*])', 2), self.check('[1].keyName', policy_name), self.check('[1].rights', right) ]) # Get access policy - self.cmd('az iot dps access-policy show -g {} --dps-name {} -n {}'.format(group_name, dps_name, policy_name), checks=[ + self.cmd('az iot dps policy show -g {} --dps-name {} -n {}'.format(group_name, dps_name, policy_name), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # Create update policy - self.cmd('az iot dps access-policy update -g {} --dps-name {} -n {} -r {}'.format(group_name, dps_name, policy_name, new_right), + self.cmd('az iot dps policy update -g {} --dps-name {} -n {} -r {}'.format(group_name, dps_name, policy_name, new_right), checks=[ self.check('keyName', policy_name), self.check('rights', new_right) ]) # Delete policy - self.cmd('az iot dps access-policy delete -g {} --dps-name {} -n {}'.format(group_name, dps_name, policy_name)) + self.cmd('az iot dps policy delete -g {} --dps-name {} -n {}'.format(group_name, dps_name, policy_name)) # Test DPS Certificate Lifecycle cert_name = self.create_random_name('certificate', 20) From ff31b0af73bdd3cf1129439f431997029cee43ab Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Mon, 4 Apr 2022 11:03:36 -0700 Subject: [PATCH 2/9] update params --- .../azure/cli/command_modules/iot/_params.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index 26faae83c37..d959a9e6dd9 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -78,8 +78,12 @@ def load_arguments(self, _): # pylint: disable=too-many-statements 'cross geo-pair disaster recovery. This property is immutable once set on the resource. ' 'Only available in select regions. Learn more at https://aka.ms/dpsdr') + for subgroup in ['policy', 'linked-hub', 'certificate']: + with self.argument_context('iot dps {}'.format(subgroup)) as c: + c.argument('dps_name', options_list=['--dps-name'], id_part=None) + with self.argument_context('iot dps policy') as c: - c.argument('access_policy_name', options_list=['--policy-name', '--pn'], + c.argument('access_policy_name', options_list=['--policy-name', '--pn', '--name', '-n'], help='A friendly name for DPS access policy.') for subgroup in ['create', 'update']: @@ -98,7 +102,10 @@ def load_arguments(self, _): # pylint: disable=too-many-statements c.argument('connection_string', help='Connection string of the IoT hub. Required if hub name is not provided using --hub-name.', arg_group='IoT Hub Identifier') - c.argument('hub_name', help='IoT Hub name.', arg_group='IoT Hub Identifier') + c.argument('hub_name', + options_list=['--hub-name', '--hn'], + help='IoT Hub name.', + arg_group='IoT Hub Identifier') c.argument('hub_resource_group', options_list=['--hub-resource-group', '--hrg'], help='IoT Hub resource group name.', From a1697a78f3ac7f36a296c609eee1545812e91f82 Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Mon, 4 Apr 2022 11:27:32 -0700 Subject: [PATCH 3/9] style changes --- src/azure-cli/azure/cli/command_modules/iot/_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index d959a9e6dd9..66a9af543b8 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -89,8 +89,8 @@ def load_arguments(self, _): # pylint: disable=too-many-statements for subgroup in ['create', 'update']: with self.argument_context('iot dps policy {}'.format(subgroup)) as c: c.argument('rights', options_list=['--rights', '-r'], nargs='+', - arg_type=get_enum_type(AccessRightsDescription), - help='Access rights for the IoT Hub Device Provisioning Service. ' + arg_type=get_enum_type(AccessRightsDescription), + help='Access rights for the IoT Hub Device Provisioning Service. ' 'Use space-separated list for multiple rights.') c.argument('primary_key', help='Primary SAS key value.') c.argument('secondary_key', help='Secondary SAS key value.') From 587eb920ab8f560d4cbad989c8f919993229750f Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Tue, 5 Apr 2022 11:43:01 -0700 Subject: [PATCH 4/9] fix param --- src/azure-cli/azure/cli/command_modules/iot/_params.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index 66a9af543b8..1a26fdc9d7e 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -16,7 +16,6 @@ from azure.mgmt.iotcentral.models import AppSku from azure.mgmt.iothub.models import IotHubSku from azure.mgmt.iothubprovisioningservices.models import (IotDpsSku, - AllocationPolicy, AccessRightsDescription) from azure.cli.command_modules.iot.shared import (EndpointType, RouteSourceType, @@ -78,12 +77,13 @@ def load_arguments(self, _): # pylint: disable=too-many-statements 'cross geo-pair disaster recovery. This property is immutable once set on the resource. ' 'Only available in select regions. Learn more at https://aka.ms/dpsdr') - for subgroup in ['policy', 'linked-hub', 'certificate']: + # plan to slowly align this with extension naming patterns - name should be aligned with dps_name + for subgroup in ['linked-hub', 'certificate']: with self.argument_context('iot dps {}'.format(subgroup)) as c: c.argument('dps_name', options_list=['--dps-name'], id_part=None) with self.argument_context('iot dps policy') as c: - c.argument('access_policy_name', options_list=['--policy-name', '--pn', '--name', '-n'], + c.argument('access_policy_name', options_list=['--policy-name', '--pn'], help='A friendly name for DPS access policy.') for subgroup in ['create', 'update']: @@ -125,10 +125,6 @@ def load_arguments(self, _): # pylint: disable=too-many-statements arg_type=get_three_state_flag()) c.argument('allocation_weight', help='Allocation weight of the IoT hub.') - with self.argument_context('iot dps allocation-policy update') as c: - c.argument('allocation_policy', options_list=['--policy', '-p'], arg_type=get_enum_type(AllocationPolicy), - help='Allocation policy for the IoT Hub Device Provisioning Service.') - with self.argument_context('iot dps certificate') as c: c.argument('certificate_path', options_list=['--path', '-p'], type=file_type, completer=FilesCompleter([".cer", ".pem"]), help='The path to the file containing the certificate.') From c4cc1240935b6d717100f963fc731813e1fddf62 Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Tue, 5 Apr 2022 11:45:57 -0700 Subject: [PATCH 5/9] fix tests --- .../iot/tests/latest/test_iot_dps_commands.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py b/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py index bb6c240d9e3..96becd2183b 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py +++ b/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py @@ -66,33 +66,33 @@ def test_dps_lifecycle(self, group_name, group_location): new_right = 'EnrollmentWrite' # Create access policy - self.cmd('az iot dps policy create -g {} --dps-name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ + self.cmd('az iot dps policy create -g {} --name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # List access policy - self.cmd('az iot dps policy list -g {} --dps-name {}'.format(group_name, dps_name), checks=[ + self.cmd('az iot dps policy list -g {} --name {}'.format(group_name, dps_name), checks=[ self.check('length([*])', 2), self.check('[1].keyName', policy_name), self.check('[1].rights', right) ]) # Get access policy - self.cmd('az iot dps policy show -g {} --dps-name {} --pn {}'.format(group_name, dps_name, policy_name), checks=[ + self.cmd('az iot dps policy show -g {} --name {} --pn {}'.format(group_name, dps_name, policy_name), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # Create update policy - self.cmd('az iot dps policy update -g {} --dps-name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, new_right), + self.cmd('az iot dps policy update -g {} --name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, new_right), checks=[ self.check('keyName', policy_name), self.check('rights', new_right) ]) # Delete policy - self.cmd('az iot dps policy delete -g {} --dps-name {} --pn {}'.format(group_name, dps_name, policy_name)) + self.cmd('az iot dps policy delete -g {} --name {} --pn {}'.format(group_name, dps_name, policy_name)) # Delete DPS self.cmd('az iot dps delete -g {} -n {}'.format(group_name, dps_name)) From 324f40844ca06a1132a4fcf935143048d228d776 Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Tue, 5 Apr 2022 13:11:18 -0700 Subject: [PATCH 6/9] update params --- src/azure-cli/azure/cli/command_modules/iot/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index 1a26fdc9d7e..52a7d110012 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -61,7 +61,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements # Arguments for IoT DPS with self.argument_context('iot dps') as c: - c.argument('dps_name', dps_name_type, options_list=['--name', '-n'], id_part='name') + c.argument('dps_name', dps_name_type, options_list=['--dps-name', '--name', '-n'], id_part='name') c.argument('tags', tags_type) with self.argument_context('iot dps create') as c: From bbb8f9bb2ecd4e336b9f5267ae6070d77db4ff76 Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Tue, 5 Apr 2022 14:31:30 -0700 Subject: [PATCH 7/9] update params --- src/azure-cli/azure/cli/command_modules/iot/_params.py | 7 ++++++- .../iot/tests/latest/test_iot_dps_commands.py | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index 52a7d110012..815ff6d28e8 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -61,7 +61,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements # Arguments for IoT DPS with self.argument_context('iot dps') as c: - c.argument('dps_name', dps_name_type, options_list=['--dps-name', '--name', '-n'], id_part='name') + c.argument('dps_name', dps_name_type, options_list=['--name', '-n'], id_part='name') c.argument('tags', tags_type) with self.argument_context('iot dps create') as c: @@ -82,6 +82,11 @@ def load_arguments(self, _): # pylint: disable=too-many-statements with self.argument_context('iot dps {}'.format(subgroup)) as c: c.argument('dps_name', options_list=['--dps-name'], id_part=None) + # To replace above + for subgroup in ['policy']: + with self.argument_context('iot dps {}'.format(subgroup)) as c: + c.argument('dps_name', options_list=['--dps-name', '-n'], id_part=None) + with self.argument_context('iot dps policy') as c: c.argument('access_policy_name', options_list=['--policy-name', '--pn'], help='A friendly name for DPS access policy.') diff --git a/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py b/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py index 96becd2183b..bb6c240d9e3 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py +++ b/src/azure-cli/azure/cli/command_modules/iot/tests/latest/test_iot_dps_commands.py @@ -66,33 +66,33 @@ def test_dps_lifecycle(self, group_name, group_location): new_right = 'EnrollmentWrite' # Create access policy - self.cmd('az iot dps policy create -g {} --name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ + self.cmd('az iot dps policy create -g {} --dps-name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # List access policy - self.cmd('az iot dps policy list -g {} --name {}'.format(group_name, dps_name), checks=[ + self.cmd('az iot dps policy list -g {} --dps-name {}'.format(group_name, dps_name), checks=[ self.check('length([*])', 2), self.check('[1].keyName', policy_name), self.check('[1].rights', right) ]) # Get access policy - self.cmd('az iot dps policy show -g {} --name {} --pn {}'.format(group_name, dps_name, policy_name), checks=[ + self.cmd('az iot dps policy show -g {} --dps-name {} --pn {}'.format(group_name, dps_name, policy_name), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # Create update policy - self.cmd('az iot dps policy update -g {} --name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, new_right), + self.cmd('az iot dps policy update -g {} --dps-name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, new_right), checks=[ self.check('keyName', policy_name), self.check('rights', new_right) ]) # Delete policy - self.cmd('az iot dps policy delete -g {} --name {} --pn {}'.format(group_name, dps_name, policy_name)) + self.cmd('az iot dps policy delete -g {} --dps-name {} --pn {}'.format(group_name, dps_name, policy_name)) # Delete DPS self.cmd('az iot dps delete -g {} -n {}'.format(group_name, dps_name)) From 620b4ba6375152c75f65f7c6688c6d581c65857a Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Tue, 5 Apr 2022 15:02:59 -0700 Subject: [PATCH 8/9] update tests --- .../iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py b/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py index 24fc72a0116..a319451c3a5 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py +++ b/src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/test_iot_dps_commands.py @@ -58,7 +58,7 @@ def test_dps_lifecycle(self, group_name, group_location): new_right = 'EnrollmentWrite' # Create access policy - self.cmd('az iot dps policy create -g {} --dps-name {} -n {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ + self.cmd('az iot dps policy create -g {} --dps-name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, right), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) @@ -71,20 +71,20 @@ def test_dps_lifecycle(self, group_name, group_location): ]) # Get access policy - self.cmd('az iot dps policy show -g {} --dps-name {} -n {}'.format(group_name, dps_name, policy_name), checks=[ + self.cmd('az iot dps policy show -g {} --dps-name {} --pn {}'.format(group_name, dps_name, policy_name), checks=[ self.check('keyName', policy_name), self.check('rights', right) ]) # Create update policy - self.cmd('az iot dps policy update -g {} --dps-name {} -n {} -r {}'.format(group_name, dps_name, policy_name, new_right), + self.cmd('az iot dps policy update -g {} --dps-name {} --pn {} -r {}'.format(group_name, dps_name, policy_name, new_right), checks=[ self.check('keyName', policy_name), self.check('rights', new_right) ]) # Delete policy - self.cmd('az iot dps policy delete -g {} --dps-name {} -n {}'.format(group_name, dps_name, policy_name)) + self.cmd('az iot dps policy delete -g {} --dps-name {} --pn {}'.format(group_name, dps_name, policy_name)) # Test DPS Certificate Lifecycle cert_name = self.create_random_name('certificate', 20) From 8e0508d3d2021458dc4e041ecca6c1b08cdce6d2 Mon Sep 17 00:00:00 2001 From: Victoria Litvinova Date: Tue, 5 Apr 2022 15:04:21 -0700 Subject: [PATCH 9/9] nit param comment --- src/azure-cli/azure/cli/command_modules/iot/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/iot/_params.py b/src/azure-cli/azure/cli/command_modules/iot/_params.py index 815ff6d28e8..64c45650f97 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/_params.py +++ b/src/azure-cli/azure/cli/command_modules/iot/_params.py @@ -77,7 +77,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements 'cross geo-pair disaster recovery. This property is immutable once set on the resource. ' 'Only available in select regions. Learn more at https://aka.ms/dpsdr') - # plan to slowly align this with extension naming patterns - name should be aligned with dps_name + # plan to slowly align this with extension naming patterns - n should be aligned with dps_name for subgroup in ['linked-hub', 'certificate']: with self.argument_context('iot dps {}'.format(subgroup)) as c: c.argument('dps_name', options_list=['--dps-name'], id_part=None)