Skip to content

Commit 1c11174

Browse files
c-ryan-kvilit1
andauthored
[IoT] DPS track 2 update, access-policy deprecation, and linked-hub parameter changes (Azure#20682)
* DPS track 2 updates * Dps track 2 core changes (#3) * Change rg to be optional Deprecate access-policy to policy Add hub name parameter options to linked hub Bucket arguments * support name or host name in linked hub * update wording to have DPS later * update expiration * Added key filter on DPS tests and re-recorded * Linter and param fixes * Fixed up extra key in tests * Use more specific CLI error types * Added comments to sharedaccesskey processor regex Co-authored-by: Ryan Kelly <[email protected]> Co-authored-by: Victoria Litvinova <[email protected]>
1 parent 3b6d9df commit 1c11174

16 files changed

+7777
-3535
lines changed

linter_exclusions.yml

+8
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,9 @@ iot dps linked-hub create:
20092009
apply_allocation_policy:
20102010
rule_exclusions:
20112011
- option_length_too_long
2012+
hub_resource_group:
2013+
rule_exclusions:
2014+
- parameter_should_not_end_in_resource_group
20122015
iot dps linked-hub update:
20132016
parameters:
20142017
apply_allocation_policy:
@@ -2029,6 +2032,11 @@ iot hub policy list:
20292032
iot hub route list:
20302033
rule_exclusions:
20312034
- no_ids_for_list_commands
2035+
iot hub routing-endpoint create:
2036+
parameters:
2037+
endpoint_resource_group:
2038+
rule_exclusions:
2039+
- parameter_should_not_end_in_resource_group
20322040
iot hub routing-endpoint list:
20332041
rule_exclusions:
20342042
- no_ids_for_list_commands

src/azure-cli-core/azure/cli/core/profiles/_shared.py

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
6464
MGMT_APPSERVICE = ('azure.mgmt.web', 'WebSiteManagementClient')
6565
MGMT_IOTCENTRAL = ('azure.mgmt.iotcentral', 'IotCentralClient')
6666
MGMT_IOTHUB = ('azure.mgmt.iothub', 'IotHubClient')
67+
MGMT_IOTDPS = ('azure.mgmt.iothubprovisioningservices', 'IotDpsClient')
6768
MGMT_ARO = ('azure.mgmt.redhatopenshift', 'AzureRedHatOpenShift4Client')
6869
MGMT_DATABOXEDGE = ('azure.mgmt.databoxedge', 'DataBoxEdgeManagementClient')
6970
MGMT_CUSTOMLOCATION = ('azure.mgmt.extendedlocation', 'CustomLocations')
@@ -227,6 +228,7 @@ def default_api_version(self):
227228
}),
228229
ResourceType.MGMT_APPSERVICE: '2020-09-01',
229230
ResourceType.MGMT_IOTHUB: '2021-07-01',
231+
ResourceType.MGMT_IOTDPS: '2020-03-01',
230232
ResourceType.MGMT_IOTCENTRAL: '2018-09-01',
231233
ResourceType.MGMT_ARO: '2020-04-30',
232234
ResourceType.MGMT_DATABOXEDGE: '2021-02-01-preview',

src/azure-cli/azure/cli/command_modules/iot/_client_factory.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def resource_service_factory(cli_ctx, **_):
1818

1919
def iot_service_provisioning_factory(cli_ctx, *_):
2020
from azure.cli.core.commands.client_factory import get_mgmt_service_client
21-
from azure.mgmt.iothubprovisioningservices import IotDpsClient
22-
return get_mgmt_service_client(cli_ctx, IotDpsClient)
21+
from azure.cli.core.profiles import ResourceType
22+
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_IOTDPS)
2323

2424

2525
def iot_central_service_factory(cli_ctx, *_):

src/azure-cli/azure/cli/command_modules/iot/_help.py

+98-48
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/iot/_params.py

+48-10
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
dps_name_type = CLIArgumentType(
4545
options_list=['--dps-name'],
4646
completer=get_resource_name_completion_list('Microsoft.Devices/ProvisioningServices'),
47-
help='IoT Provisioning Service name')
47+
help='IoT Hub Device Provisioning Service name')
4848

4949
app_name_type = CLIArgumentType(
5050
completer=get_resource_name_completion_list('Microsoft.IoTCentral/IoTApps'),
@@ -67,40 +67,78 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
6767

6868
with self.argument_context('iot dps create') as c:
6969
c.argument('location', get_location_type(self.cli_ctx),
70-
help='Location of your IoT Provisioning Service. Default is the location of target resource group.')
70+
help='Location of your IoT Hub Device Provisioning Service. '
71+
'Default is the location of target resource group.')
7172
c.argument('sku', arg_type=get_enum_type(IotDpsSku),
72-
help='Pricing tier for the IoT provisioning service.')
73-
c.argument('unit', help='Units in your IoT Provisioning Service.', type=int)
73+
help='Pricing tier for the IoT Hub Device Provisioning Service.')
74+
c.argument('unit', help='Units in your IoT Hub Device Provisioning Service.', type=int)
7475

76+
# To deprecate
7577
for subgroup in ['access-policy', 'linked-hub', 'certificate']:
7678
with self.argument_context('iot dps {}'.format(subgroup)) as c:
7779
c.argument('dps_name', options_list=['--dps-name'], id_part=None)
7880

81+
# To replace deprecated
82+
for subgroup in ['policy']:
83+
with self.argument_context('iot dps {}'.format(subgroup)) as c:
84+
c.argument('dps_name', options_list=['--dps-name', '-n'], id_part=None)
85+
7986
with self.argument_context('iot dps access-policy') as c:
8087
c.argument('access_policy_name', options_list=['--access-policy-name', '--name', '-n'],
81-
help='A friendly name for DPS access policy.')
88+
help='A friendly name for DPS shared access policy.')
8289

8390
with self.argument_context('iot dps access-policy create') as c:
8491
c.argument('rights', options_list=['--rights', '-r'], nargs='+',
8592
arg_type=get_enum_type(AccessRightsDescription),
86-
help='Access rights for the IoT provisioning service. Use space-separated list for multiple rights.')
93+
help='Access rights for the IoT Hub Device Provisioning Service. '
94+
'Use space-separated list for multiple rights.')
8795
c.argument('primary_key', help='Primary SAS key value.')
8896
c.argument('secondary_key', help='Secondary SAS key value.')
8997

9098
with self.argument_context('iot dps access-policy update') as c:
9199
c.argument('rights', options_list=['--rights', '-r'], nargs='+',
92100
arg_type=get_enum_type(AccessRightsDescription),
93-
help='Access rights for the IoT provisioning service. Use space-separated list for multiple rights.')
101+
help='Access rights for the IoT Hub Device Provisioning Service. '
102+
'Use space-separated list for multiple rights.')
103+
c.argument('primary_key', help='Primary SAS key value.')
104+
c.argument('secondary_key', help='Secondary SAS key value.')
105+
106+
with self.argument_context('iot dps policy') as c:
107+
c.argument('access_policy_name', options_list=['--policy-name', '--pn'],
108+
help='A friendly name for DPS access policy.')
109+
110+
with self.argument_context('iot dps policy create') as c:
111+
c.argument('rights', options_list=['--rights', '-r'], nargs='+',
112+
arg_type=get_enum_type(AccessRightsDescription),
113+
help='Access rights for the IoT Hub Device Provisioning Service. '
114+
'Use space-separated list for multiple rights.')
115+
c.argument('primary_key', help='Primary SAS key value.')
116+
c.argument('secondary_key', help='Secondary SAS key value.')
117+
118+
with self.argument_context('iot dps policy update') as c:
119+
c.argument('rights', options_list=['--rights', '-r'], nargs='+',
120+
arg_type=get_enum_type(AccessRightsDescription),
121+
help='Access rights for the IoT Hub Device Provisioning Service. '
122+
'Use space-separated list for multiple rights.')
94123
c.argument('primary_key', help='Primary SAS key value.')
95124
c.argument('secondary_key', help='Secondary SAS key value.')
96125

97126
with self.argument_context('iot dps linked-hub') as c:
98127
c.argument('linked_hub', options_list=['--linked-hub'], help='Host name of linked IoT Hub.')
99128

100129
with self.argument_context('iot dps linked-hub create') as c:
101-
c.argument('connection_string', help='Connection string of the IoT hub.')
130+
c.argument('connection_string',
131+
help='Connection string of the IoT hub. Required if hub name is not provided using --hub-name.',
132+
arg_group='IoT Hub Identifier')
133+
c.argument('hub_name', help='IoT Hub name.', arg_group='IoT Hub Identifier')
134+
c.argument('hub_resource_group',
135+
options_list=['--hub-resource-group', '--hrg'],
136+
help='IoT Hub resource group name.',
137+
arg_group='IoT Hub Identifier')
102138
c.argument('location', get_location_type(self.cli_ctx),
103-
help='Location of the IoT hub.')
139+
help='Location of the IoT hub.',
140+
arg_group='IoT Hub Identifier',
141+
deprecate_info=c.deprecate(hide=True))
104142
c.argument('apply_allocation_policy',
105143
help='A boolean indicating whether to apply allocation policy to the IoT hub.',
106144
arg_type=get_three_state_flag())
@@ -114,7 +152,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
114152

115153
with self.argument_context('iot dps allocation-policy update') as c:
116154
c.argument('allocation_policy', options_list=['--policy', '-p'], arg_type=get_enum_type(AllocationPolicy),
117-
help='Allocation policy for the IoT provisioning service.')
155+
help='Allocation policy for the IoT Hub Device Provisioning Service.')
118156

119157
with self.argument_context('iot dps certificate') as c:
120158
c.argument('certificate_path', options_list=['--path', '-p'], type=file_type,

src/azure-cli/azure/cli/command_modules/iot/commands.py

+19-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ def load_command_table(self, _): # pylint: disable=too-many-statements
5959
g.generic_update_command('update', getter_name='iot_dps_get', setter_name='iot_dps_update',
6060
command_type=update_custom_util)
6161

62-
# iot dps access-policy commands
63-
with self.command_group('iot dps access-policy', client_factory=iot_service_provisioning_factory) as g:
64-
g.custom_command('list', 'iot_dps_access_policy_list')
65-
g.custom_show_command('show', 'iot_dps_access_policy_get')
66-
g.custom_command('create', 'iot_dps_access_policy_create', supports_no_wait=True)
67-
g.custom_command('update', 'iot_dps_access_policy_update', supports_no_wait=True)
68-
g.custom_command('delete', 'iot_dps_access_policy_delete', supports_no_wait=True)
62+
# iot dps access-policy commands (Deprecated)
63+
with self.command_group('iot dps access-policy',
64+
client_factory=iot_service_provisioning_factory,
65+
deprecate_info=self.deprecate(redirect='iot dps policy',
66+
expiration='2.35.0')
67+
) as g:
68+
g.custom_command('list', 'iot_dps_policy_list')
69+
g.custom_show_command('show', 'iot_dps_policy_get')
70+
g.custom_command('create', 'iot_dps_policy_create', supports_no_wait=True)
71+
g.custom_command('update', 'iot_dps_policy_update', supports_no_wait=True)
72+
g.custom_command('delete', 'iot_dps_policy_delete', supports_no_wait=True)
6973

7074
# iot dps linked-hub commands
7175
with self.command_group('iot dps linked-hub', client_factory=iot_service_provisioning_factory) as g:
@@ -85,6 +89,14 @@ def load_command_table(self, _): # pylint: disable=too-many-statements
8589
g.custom_command('verify', 'iot_dps_certificate_verify')
8690
g.custom_command('update', 'iot_dps_certificate_update')
8791

92+
# iot dps policy commands
93+
with self.command_group('iot dps policy', client_factory=iot_service_provisioning_factory) as g:
94+
g.custom_command('list', 'iot_dps_policy_list')
95+
g.custom_show_command('show', 'iot_dps_policy_get')
96+
g.custom_command('create', 'iot_dps_policy_create', supports_no_wait=True)
97+
g.custom_command('update', 'iot_dps_policy_update', supports_no_wait=True)
98+
g.custom_command('delete', 'iot_dps_policy_delete', supports_no_wait=True)
99+
88100
# iot hub certificate commands
89101
with self.command_group('iot hub certificate', client_factory=iot_hub_service_factory) as g:
90102
g.custom_command('list', 'iot_hub_certificate_list')

0 commit comments

Comments
 (0)