Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion azext_iot/core/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
help='IoT Hub name.')

dps_name_type = CLIArgumentType(
options_list=['--dps-name', '--name'],
options_list=['--dps-name', '--name', '-n'],
completer=get_resource_name_completion_list('Microsoft.Devices/ProvisioningServices'),
help='IoT Hub Device Provisioning Service name')

Expand Down
4 changes: 2 additions & 2 deletions azext_iot/core/command_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ def load_core_commands(self, _):
with self.command_group(
"iot hub", command_type=core_ops, client_factory=iot_hub_service_factory
) as cmd_group:
cmd_group.command("create", "iot_hub_create")
cmd_group.command("create", "iot_hub_create", supports_no_wait=True)
cmd_group.generic_update_command(
"update",
getter_name="iot_hub_get",
setter_name="iot_hub_update",
custom_func_type=core_ops,
custom_func_name="update_iot_hub_custom",
)
cmd_group.command("delete", "iot_hub_delete")
cmd_group.command("delete", "iot_hub_delete", supports_no_wait=True)
cmd_group.show_command("show", "iot_hub_get")
cmd_group.command("list", "iot_hub_list")
cmd_group.command('list-skus', 'iot_hub_sku_list')
Expand Down
36 changes: 19 additions & 17 deletions azext_iot/core/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from azext_iot._factory import iot_hub_service_factory, resource_service_factory
from azext_iot.common.certops import open_certificate
from azext_iot.common.shared import AuthenticationType
from azext_iot.sdk.iothub.mgmt.models import AuthenticationType
from azext_iot.core.shared import (
ADR_CONFIGURE_ROLES_ERROR_MSG,
ADR_NS_IDENTITY_ROLES_FOR_HUB,
Expand Down Expand Up @@ -535,7 +535,8 @@ def iot_dps_certificate_update(client, dps_name, certificate_name, certificate_p
provisioning_service_name=dps_name,
certificate_name=certificate_name,
certificate_description=certificate_description,
etag=etag
etag=etag,
match_condition=MatchConditions.IfNotModified
)
raise CLIError("Certificate '{0}' does not exist. Use 'iot dps certificate create' to create a new certificate."
.format(certificate_name))
Expand Down Expand Up @@ -734,7 +735,7 @@ def iot_hub_create(
raise RequiredArgumentMissingError('Please mention storage container name.')
if fileupload_storage_container_name and not fileupload_storage_connectionstring:
raise RequiredArgumentMissingError('Please mention storage connection string.')
identity_based_file_upload = fileupload_storage_authentication_type and fileupload_storage_authentication_type == AuthenticationType.IdentityBased.value
identity_based_file_upload = fileupload_storage_authentication_type and fileupload_storage_authentication_type == AuthenticationType.IDENTITY_BASED.value
if not identity_based_file_upload and fileupload_storage_identity:
raise RequiredArgumentMissingError('In order to set a fileupload storage identity, please set file upload storage authentication (--fsa) to IdentityBased')
if identity_based_file_upload or fileupload_storage_identity:
Expand Down Expand Up @@ -927,7 +928,7 @@ def update_iot_hub_custom(instance,
default_storage_endpoint = StorageEndpointProperties(container_name=fileupload_storage_container_name, connection_string=fileupload_storage_connectionstring)

# if setting a fileupload storage identity or changing fileupload to identity-based
if fileupload_storage_identity or fileupload_storage_authentication_type == AuthenticationType.IdentityBased.value:
if fileupload_storage_identity or fileupload_storage_authentication_type == AuthenticationType.IDENTITY_BASED.value:
_validate_fileupload_identity(instance, fileupload_storage_identity)

instance.properties.storage_endpoints['$default'] = _process_fileupload_args(
Expand Down Expand Up @@ -959,9 +960,10 @@ def update_iot_hub_custom(instance,
f"Cannot change IoT Hub SKU from {existing_sku_name} to {final_sku_name}."
)

adr_namespace_resource_id = instance.device_registry.namespace_resource_id if instance.device_registry else None
device_registry = getattr(instance.properties, "device_registry", None)
adr_namespace_resource_id = device_registry.namespace_resource_id if device_registry else None
_validate_and_set_adr_properties(
instance=instance,
instance=instance.properties,
sku=final_sku_name,
adr_namespace_resource_id=adr_namespace_resource_id,
adr_identity_resource_id=adr_ns_identity_id,
Expand Down Expand Up @@ -1276,7 +1278,7 @@ def iot_hub_get_stats(client, hub_name, resource_group_name=None):


def validate_authentication_type_input(endpoint_type, connection_string=None, authentication_type=None, endpoint_uri=None, entity_path=None):
is_keyBased = (AuthenticationType.KeyBased.value == authentication_type) or (authentication_type is None)
is_keyBased = (AuthenticationType.KEY_BASED.value == authentication_type) or (authentication_type is None)
has_connection_string = connection_string is not None
if is_keyBased and not has_connection_string:
raise CLIError("Please provide a connection string '--connection-string/-c'")
Expand All @@ -1298,7 +1300,7 @@ def iot_hub_routing_endpoint_create(cmd, client, hub_name, endpoint_name, endpoi
identity=None):
resource_group_name = _ensure_hub_resource_group_name(client, resource_group_name, hub_name)
hub = iot_hub_get(cmd, client, hub_name, resource_group_name)
if identity and authentication_type != AuthenticationType.IdentityBased.value:
if identity and authentication_type != AuthenticationType.IDENTITY_BASED.value:
raise ArgumentUsageError("In order to use an identity for authentication, you must select --auth-type as 'identityBased'")

if EndpointType.EventHub.value == endpoint_type.lower():
Expand Down Expand Up @@ -1497,15 +1499,15 @@ def iot_hub_route_test(cmd, client, hub_name, route_name=None, source_type=None,
route=route
)
return client.iot_hub_resource.test_route(
resource_name=hub_name, resource_group_name=resource_group_name, input=test_route_input
iot_hub_name=hub_name, resource_group_name=resource_group_name, input=test_route_input
)
test_all_routes_input = TestAllRoutesInput(
routing_source=source_type,
message=route_message,
twin=None
)
return client.iot_hub_resource.test_all_routes(
resource_name=hub_name, resource_group_name=resource_group_name, input=test_all_routes_input
iot_hub_name=hub_name, resource_group_name=resource_group_name, input=test_all_routes_input
)


Expand Down Expand Up @@ -1559,11 +1561,11 @@ def iot_hub_manual_failover(cmd, client, hub_name, resource_group_name=None, no_
failover_input = FailoverInput(failover_region=failover_region)
if no_wait:
return client.iot_hub.begin_manual_failover(
resource_name=hub_name, resource_group_name=resource_group_name, failover_input=failover_input
iot_hub_name=hub_name, resource_group_name=resource_group_name, failover_input=failover_input
)
LongRunningOperation(cmd.cli_ctx)(
client.iot_hub.begin_manual_failover(
resource_name=hub_name, resource_group_name=resource_group_name, failover_input=failover_input
iot_hub_name=hub_name, resource_group_name=resource_group_name, failover_input=failover_input
)
)
return iot_hub_get(cmd, client, hub_name, resource_group_name)
Expand Down Expand Up @@ -1712,12 +1714,12 @@ def _process_fileupload_args(
fileupload_storage_identity=None,
):
from datetime import timedelta
if fileupload_storage_authentication_type and fileupload_storage_authentication_type == AuthenticationType.IdentityBased.value:
default_storage_endpoint.authentication_type = AuthenticationType.IdentityBased.value
if fileupload_storage_authentication_type and fileupload_storage_authentication_type == AuthenticationType.IDENTITY_BASED.value:
default_storage_endpoint.authentication_type = AuthenticationType.IDENTITY_BASED.value
if fileupload_storage_container_uri:
default_storage_endpoint.container_uri = fileupload_storage_container_uri
elif fileupload_storage_authentication_type and fileupload_storage_authentication_type == AuthenticationType.KeyBased.value:
default_storage_endpoint.authentication_type = AuthenticationType.KeyBased.value
elif fileupload_storage_authentication_type and fileupload_storage_authentication_type == AuthenticationType.KEY_BASED.value:
default_storage_endpoint.authentication_type = AuthenticationType.KEY_BASED.value
default_storage_endpoint.identity = None
elif fileupload_storage_authentication_type is not None:
default_storage_endpoint.authentication_type = None
Expand All @@ -1736,7 +1738,7 @@ def _process_fileupload_args(
# Fix for identity/authentication-type params missing on hybrid profile api
if hasattr(default_storage_endpoint, 'authentication_type'):
# If we are now (or will be) using fsa=identity AND we've set a new identity
if default_storage_endpoint.authentication_type == AuthenticationType.IdentityBased.value and fileupload_storage_identity:
if default_storage_endpoint.authentication_type == AuthenticationType.IDENTITY_BASED.value and fileupload_storage_identity:
# setup new fsi
default_storage_endpoint.identity = ManagedIdentity(
user_assigned_identity=fileupload_storage_identity) if fileupload_storage_identity not in [IdentityType.none.value, SYSTEM_ASSIGNED_IDENTITY] else None
Expand Down
Loading