From 3e28cd6f7ef42e6a0e28d42b92aa5c5b45d4fa1e Mon Sep 17 00:00:00 2001 From: Ryan K Date: Thu, 29 Oct 2020 17:54:18 -0700 Subject: [PATCH] Switched DT instance create --tags parameter to common CLI tags_type property (#266) --- azext_iot/digitaltwins/_help.py | 2 +- azext_iot/digitaltwins/params.py | 4 +++- azext_iot/digitaltwins/providers/resource.py | 4 +--- azext_iot/tests/digitaltwins/__init__.py | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/azext_iot/digitaltwins/_help.py b/azext_iot/digitaltwins/_help.py index 6f6b48831..67fc1a77a 100644 --- a/azext_iot/digitaltwins/_help.py +++ b/azext_iot/digitaltwins/_help.py @@ -28,7 +28,7 @@ def load_digitaltwins_help(): - name: Create instance in target resource group with specified location and tags. text: > - az dt create -n {instance_name} -g {resouce_group} -l westcentralus --tags "a=b;c=d" + az dt create -n {instance_name} -g {resouce_group} -l westcentralus --tags a=b c=d """ helps["dt show"] = """ diff --git a/azext_iot/digitaltwins/params.py b/azext_iot/digitaltwins/params.py index 6c28305bb..90a1edfc4 100644 --- a/azext_iot/digitaltwins/params.py +++ b/azext_iot/digitaltwins/params.py @@ -12,6 +12,7 @@ from azure.cli.core.commands.parameters import ( resource_group_name_type, get_three_state_flag, + tags_type ) depfor_type = CLIArgumentType( @@ -55,7 +56,8 @@ def load_digitaltwins_arguments(self, _): context.argument( "tags", options_list=["--tags"], - help="Digital Twins instance tags. Property bag in key-value pairs with the following format: a=b;c=d.", + arg_type=tags_type, + help="Digital Twins instance tags. Property bag in key-value pairs with the following format: a=b c=d", ) context.argument( "endpoint_name", diff --git a/azext_iot/digitaltwins/providers/resource.py b/azext_iot/digitaltwins/providers/resource.py index 5f8dc34f9..97db61f7b 100644 --- a/azext_iot/digitaltwins/providers/resource.py +++ b/azext_iot/digitaltwins/providers/resource.py @@ -15,7 +15,7 @@ EventHub as EventHubEndpointProperties, ServiceBus as ServiceBusEndpointProperties, ) -from azext_iot.common.utility import validate_key_value_pairs, unpack_msrest_error +from azext_iot.common.utility import unpack_msrest_error from knack.util import CLIError @@ -26,8 +26,6 @@ def __init__(self, cmd): self.rbac = RbacProvider() def create(self, name, resource_group_name, location=None, tags=None, timeout=60): - if tags: - tags = validate_key_value_pairs(tags) if not location: from azext_iot.common.embedded_cli import EmbeddedCLI diff --git a/azext_iot/tests/digitaltwins/__init__.py b/azext_iot/tests/digitaltwins/__init__.py index be44dc153..20f06e545 100644 --- a/azext_iot/tests/digitaltwins/__init__.py +++ b/azext_iot/tests/digitaltwins/__init__.py @@ -12,8 +12,7 @@ from azext_iot.common.embedded_cli import EmbeddedCLI -MOCK_RESOURCE_TAGS = "a=b;c=d" -MOCK_ENDPOINT_TAGS = "key0=value0;key1=value1;" +MOCK_RESOURCE_TAGS = "a=b c=d" MOCK_DEAD_LETTER_SECRET = 'https://accountname.blob.core.windows.net/containerName?sasToken'