Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
8 changes: 8 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,9 @@ iot dps linked-hub create:
apply_allocation_policy:
rule_exclusions:
- option_length_too_long
hub_resource_group:
rule_exclusions:
- parameter_should_not_end_in_resource_group
iot dps linked-hub update:
parameters:
apply_allocation_policy:
Expand All @@ -2029,6 +2032,11 @@ iot hub policy list:
iot hub route list:
rule_exclusions:
- no_ids_for_list_commands
iot hub routing-endpoint create:
parameters:
endpoint_resource_group:
rule_exclusions:
- parameter_should_not_end_in_resource_group
iot hub routing-endpoint list:
rule_exclusions:
- no_ids_for_list_commands
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
MGMT_APPSERVICE = ('azure.mgmt.web', 'WebSiteManagementClient')
MGMT_IOTCENTRAL = ('azure.mgmt.iotcentral', 'IotCentralClient')
MGMT_IOTHUB = ('azure.mgmt.iothub', 'IotHubClient')
MGMT_IOTDPS = ('azure.mgmt.iothubprovisioningservices', 'IotDpsClient')
MGMT_ARO = ('azure.mgmt.redhatopenshift', 'AzureRedHatOpenShift4Client')
MGMT_DATABOXEDGE = ('azure.mgmt.databoxedge', 'DataBoxEdgeManagementClient')
MGMT_CUSTOMLOCATION = ('azure.mgmt.extendedlocation', 'CustomLocations')
Expand Down Expand Up @@ -227,6 +228,7 @@ def default_api_version(self):
}),
ResourceType.MGMT_APPSERVICE: '2020-09-01',
ResourceType.MGMT_IOTHUB: '2021-07-01',
ResourceType.MGMT_IOTDPS: '2020-03-01',
ResourceType.MGMT_IOTCENTRAL: '2018-09-01',
ResourceType.MGMT_ARO: '2020-04-30',
ResourceType.MGMT_DATABOXEDGE: '2021-02-01-preview',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def resource_service_factory(cli_ctx, **_):

def iot_service_provisioning_factory(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.iothubprovisioningservices import IotDpsClient
return get_mgmt_service_client(cli_ctx, IotDpsClient)
from azure.cli.core.profiles import ResourceType
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_IOTDPS)


def iot_central_service_factory(cli_ctx, *_):
Expand Down
146 changes: 98 additions & 48 deletions src/azure-cli/azure/cli/command_modules/iot/_help.py

Large diffs are not rendered by default.

58 changes: 48 additions & 10 deletions src/azure-cli/azure/cli/command_modules/iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
dps_name_type = CLIArgumentType(
options_list=['--dps-name'],
completer=get_resource_name_completion_list('Microsoft.Devices/ProvisioningServices'),
help='IoT Provisioning Service name')
help='IoT Hub Device Provisioning Service name')

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

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

# 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 access policy.')
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 provisioning service. Use space-separated list for multiple rights.')
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 provisioning service. Use space-separated list for multiple rights.')
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.')

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.')

with self.argument_context('iot dps linked-hub create') as c:
c.argument('connection_string', help='Connection string of the IoT hub.')
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_resource_group',
options_list=['--hub-resource-group', '--hrg'],
help='IoT Hub resource group name.',
arg_group='IoT Hub Identifier')
c.argument('location', get_location_type(self.cli_ctx),
help='Location of the IoT hub.')
help='Location of the IoT hub.',
arg_group='IoT Hub Identifier',
deprecate_info=c.deprecate(hide=True))
c.argument('apply_allocation_policy',
help='A boolean indicating whether to apply allocation policy to the IoT hub.',
arg_type=get_three_state_flag())
Expand All @@ -114,7 +152,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements

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 provisioning service.')
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,
Expand Down
26 changes: 19 additions & 7 deletions src/azure-cli/azure/cli/command_modules/iot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ 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
with self.command_group('iot dps access-policy', client_factory=iot_service_provisioning_factory) as g:
g.custom_command('list', 'iot_dps_access_policy_list')
g.custom_show_command('show', 'iot_dps_access_policy_get')
g.custom_command('create', 'iot_dps_access_policy_create', supports_no_wait=True)
g.custom_command('update', 'iot_dps_access_policy_update', supports_no_wait=True)
g.custom_command('delete', 'iot_dps_access_policy_delete', supports_no_wait=True)
# 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.35.0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expiration causes lots of failures in CI after Azure CLI is updated to 2.35.0:

https://dev.azure.com/azure-sdk/public/_build/results?buildId=1475423&view=logs&j=168ccbe3-da49-5c0b-6478-08f7016e4bf5&t=10a595be-4223-5cc7-9a73-012871b6eaee

-  FAIL - HIGH severity: faulty_help_example_parameters_rule
    Help-Entry: `iot dps access-policy create` - 
	There is a violation:
	"az iot dps access-policy create --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy --rights EnrollmentRead" is not a valid command.
	argument _subcommand: unknown parser 'access-policy' (choices: list, show, create, delete, update, linked-hub, certificate, policy).
...
-  FAIL - HIGH severity: expired_command_group
    Command-Group: `iot dps access-policy` - Deprecated command group is expired and should be removed.
...
-  FAIL - HIGH severity: missing_command_help
    Command: `iot dps access-policy create` - Missing help
    Command: `iot dps access-policy delete` - Missing help
    Command: `iot dps access-policy list` - Missing help
    Command: `iot dps access-policy show` - Missing help
    Command: `iot dps access-policy update` - Missing help

) 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:
Expand All @@ -85,6 +89,14 @@ def load_command_table(self, _): # pylint: disable=too-many-statements
g.custom_command('verify', 'iot_dps_certificate_verify')
g.custom_command('update', 'iot_dps_certificate_update')

# iot dps policy commands
with self.command_group('iot dps policy', client_factory=iot_service_provisioning_factory) 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 hub certificate commands
with self.command_group('iot hub certificate', client_factory=iot_hub_service_factory) as g:
g.custom_command('list', 'iot_hub_certificate_list')
Expand Down
Loading