Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions src/azure-cli/azure/cli/command_modules/iot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
58 changes: 14 additions & 44 deletions src/azure-cli/azure/cli/command_modules/iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,55 +78,22 @@ 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']:
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)

# 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'],
c.argument('access_policy_name', options_list=['--policy-name', '--pn', '--name', '-n'],
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.')
Expand All @@ -135,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.',
Expand Down
12 changes: 0 additions & 12 deletions src/azure-cli/azure/cli/command_modules/iot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down