Skip to content

Commit

Permalink
IoT hub Message fixes (#677)
Browse files Browse the repository at this point in the history
* help + container names removed

* fix message tests
  • Loading branch information
vilit1 committed Jul 18, 2023
1 parent a68c95b commit a5f59de
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 74 deletions.
46 changes: 24 additions & 22 deletions azext_iot/iothub/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,13 @@ def load_iothub_help():
type: command
short-summary: Update the properties of an existing Cosmos DB Container endpoint for an IoT Hub.
long-summary: |
If updating the authentication type from a key-based to identity-based Cosmos DB Container endpoint, you must provide the endpoint account (via --endpoint-account). The old primary key and secondary key will be nulled out.
If updating the authentication type from a key-based to identity-based Cosmos DB Container endpoint, you must provide the identity (via --identity) and the endpoint uri (via --endpoint-uri). The old primary key and secondary key will be nulled out.
If updating the authentication type from an identity-based to key-based Cosmos DB Container endpoint, you must provide the connection string (via --connection-string) or the primary key (via --primary-key) or the secondary key (via --secondary-key).
If updating the authentication type from an identity-based to key-based Cosmos DB Container endpoint, you must provide the connection string (via --connection-string), the primary key (via --primary-key) or the secondary key (via --secondary-key).
Container name for the endpoint cannot be changed. Account names can only be changed if containers with the same name exist in both accounts.
examples:
- name: Update a key-based Cosmos DB Container endpoint for an IoT Hub to use a new specified connection string.
- name: Update a key-based or identity-based Cosmos DB Container endpoint for an IoT Hub to use a new specified connection string.
text: >
az iot hub message-endpoint update cosmosdb-container -n {iothub_name} --en {endpoint_name} --connection-string {connection_string}
- name: Update a Cosmos DB Container endpoint for an IoT Hub to use a specified primary key and secondary key.
Expand All @@ -672,10 +674,10 @@ def load_iothub_help():
The partition key template will be the default.
text: >
az iot hub message-endpoint update cosmosdb-container -n {iothub_name} --en {endpoint_name} --pkn {partition_key_name} --identity [system]
- name: Update a Cosmos DB Container endpoint for an IoT Hub to use user assigned identity
- name: Update a key-based Cosmos DB Container endpoint for an IoT Hub to use user assigned identity (you can omit --endpoint-uri if the endpoint is already identity-based).
text: >
az iot hub message-endpoint update cosmosdb-container -n {iothub_name} --en {endpoint_name}
--identity {user_identity_resource_id}
--identity {user_identity_resource_id} --endpoint-uri {endpoint_uri}
"""

helps[
Expand All @@ -684,20 +686,20 @@ def load_iothub_help():
type: command
short-summary: Update the properties of an existing Event Hub endpoint for an IoT Hub.
long-summary: |
If updating the authentication type from a key-based to identity-based Event Hub endpoint, you must provide the endpoint uri (via --endpoint-uri) and the entity path (via --entity-path). The old connection string will be nulled out.
If updating the authentication type from a key-based to identity-based Event Hub endpoint, you must provide the identity (via --identity), the endpoint uri (via --endpoint-uri) and the entity path (via --entity-path). The old connection string will be nulled out.
If updating the authentication type from an identity-based to key-based Event Hub endpoint, you must provide the connection string (via --connection-string). The old endpoint uri and entity path will be nulled out.
examples:
- name: Update an Event Hub endpoint for an IoT Hub to use a new specified connection string.
- name: Update a key-based or identity-based Event Hub endpoint for an IoT Hub to use a new specified connection string.
text: >
az iot hub message-endpoint update eventhub -n {iothub_name} --en {endpoint_name} -c {connection_string}
- name: Update an Event Hub endpoint for an IoT Hub to use system assigned identity and a different entity path.
text: >
az iot hub message-endpoint update eventhub -n {iothub_name} --en {endpoint_name}
--entity-path {entity_path} --identity [system]
- name: Update an Event Hub endpoint for an IoT Hub to use user assigned identity.
- name: Update a key-based Event Hub endpoint for an IoT Hub to use user assigned identity (you can omit --endpoint-uri if the endpoint is already identity-based).
text: >
az iot hub message-endpoint update eventhub -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id}
az iot hub message-endpoint update eventhub -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id} --endpoint-uri {endpoint_uri} --entity-path {entity_path}
"""

helps[
Expand All @@ -706,20 +708,20 @@ def load_iothub_help():
type: command
short-summary: Update the properties of an existing Service Bus Queue endpoint for an IoT Hub.
long-summary: |
If updating the authentication type from a key-based to identity-based Service Bus Queue endpoint, you must provide the endpoint uri (via --endpoint-uri) and the entity path (via --entity-path). The old connection string will be nulled out.
If updating the authentication type from a key-based to identity-based Service Bus Queue endpoint, you must provide the identity (via --identity), the endpoint uri (via --endpoint-uri) and the entity path (via --entity-path). The old connection string will be nulled out.
If updating the authentication type from an identity-based to key-based Service Bus Queue endpoint, you must provide the connection string (via --connection-string). The old endpoint uri and entity path will be nulled out.
examples:
- name: Update a Service Bus Queue endpoint for an IoT Hub to use a new specified connection string.
- name: Update a key-based or identity-based Service Bus Queue endpoint for an IoT Hub to use a new specified connection string.
text: >
az iot hub message-endpoint update servicebus-queue -n {iothub_name} --en {endpoint_name} -c {connection_string}
- name: Update a Service Bus Queue endpoint for an IoT Hub to use system assigned identity and a different entity path.
text: >
az iot hub message-endpoint update servicebus-queue -n {iothub_name} --en {endpoint_name}
--entity-path {entity_path} --identity [system]
- name: Update a Service Bus Queue endpoint for an IoT Hub to use user assigned identity.
- name: Update a key-based Service Bus Queue endpoint for an IoT Hub to use user assigned identity (you can omit --endpoint-uri if the endpoint is already identity-based).
text: >
az iot hub message-endpoint update servicebus-queue -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id}
az iot hub message-endpoint update servicebus-queue -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id} --endpoint-uri {endpoint_uri} --entity-path {entity_path}
"""

helps[
Expand All @@ -728,20 +730,20 @@ def load_iothub_help():
type: command
short-summary: Update the properties of an existing Service Bus Topic endpoint for an IoT Hub.
long-summary: |
If updating the authentication type from a key-based to identity-based Service Bus Topic endpoint, you must provide the endpoint uri (via --endpoint-uri) and the entity path (via --entity-path). The old connection string will be nulled out.
If updating the authentication type from a key-based to identity-based Service Bus Topic endpoint, you must provide the identity (via --identity), the endpoint uri (via --endpoint-uri) and the entity path (via --entity-path). The old connection string will be nulled out.
If updating the authentication type from an identity-based to key-based Service Bus Topic endpoint, you must provide the connection string (via --connection-string). The old endpoint uri and entity path will be nulled out.
examples:
- name: Update a Service Bus Topic endpoint for an IoT Hub to use a new specified connection string.
- name: Update a key-based or identity-based Service Bus Topic endpoint for an IoT Hub to use a new specified connection string.
text: >
az iot hub message-endpoint update servicebus-topic -n {iothub_name} --en {endpoint_name} -c {connection_string}
- name: Update a Service Bus Topic endpoint for an IoT Hub to use system assigned identity and a different entity path.
text: >
az iot hub message-endpoint update servicebus-topic -n {iothub_name} --en {endpoint_name}
--entity-path {entity_path} --identity [system]
- name: Update a Service Bus Topic endpoint for an IoT Hub to use user assigned identity.
- name: Update a key-based Service Bus Topic endpoint for an IoT Hub to use user assigned identity (you can omit --endpoint-uri if the endpoint is already identity-based).
text: >
az iot hub message-endpoint update servicebus-topic -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id}
az iot hub message-endpoint update servicebus-topic -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id} --endpoint-uri {endpoint_uri} --entity-path {entity_path}
"""

helps[
Expand All @@ -750,21 +752,21 @@ def load_iothub_help():
type: command
short-summary: Update the properties of an existing Storage Container endpoint for an IoT Hub.
long-summary: |
If updating the authentication type from a key-based to identity-based Storage Container endpoint, you must provide the endpoint account (via --endpoint-account). The old connection string will be nulled out.
If updating the authentication type from a key-based to identity-based Storage Container endpoint, you must provide the identity (via --identity) and the endpoint uri (via --endpoint-uri). The old connection string will be nulled out.
If updating the authentication type from an identity-based to key-based Storage Container endpoint, you must provide the connection string (via --connection-string).
Encoding for the endpoint cannot be changed.
Container name and encoding for the endpoint cannot be changed. Account names can only be changed if containers with the same name exist in both accounts.
examples:
- name: Update a Storage Container endpoint for an IoT Hub to use a new specified connection string.
- name: Update a key-based or identity-based Storage Container endpoint for an IoT Hub to use a new specified connection string.
text: >
az iot hub message-endpoint update storage-container -n {iothub_name} --en {endpoint_name} -c {connection_string}
- name: Update a Storage Container endpoint for an IoT Hub to use system assigned identity with the given batch frequency, chunk size, and file name format.
text: >
az iot hub message-endpoint update storage-container -n {iothub_name} --en {endpoint_name} -b {batch_frequency} -w {chunk_size} --ff {file_format} --identity [system]
- name: Update a Storage Container endpoint for an IoT Hub to use user assigned identity.
- name: Update a key-based Storage Container endpoint for an IoT Hub to use user assigned identity (you can omit --endpoint-uri if the endpoint is already identity-based).
text: >
az iot hub message-endpoint update storage-container -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id}
az iot hub message-endpoint update storage-container -n {iothub_name} --en {endpoint_name} --identity {user_identity_resource_id} --endpoint-uri {endpoint_uri}
"""

helps[
Expand Down
4 changes: 0 additions & 4 deletions azext_iot/iothub/commands_message_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ def message_endpoint_update_cosmos_db_container(
cmd,
hub_name: str,
endpoint_name: str,
container_name: Optional[str] = None,
database_name: Optional[str] = None,
endpoint_resource_group: Optional[str] = None,
endpoint_subscription_id: Optional[str] = None,
Expand All @@ -288,7 +287,6 @@ def message_endpoint_update_cosmos_db_container(
endpoint_subscription_id=endpoint_subscription_id,
connection_string=connection_string,
endpoint_uri=endpoint_uri,
container_name=container_name,
database_name=database_name,
primary_key=primary_key,
secondary_key=secondary_key,
Expand All @@ -302,7 +300,6 @@ def message_endpoint_update_storage_container(
cmd,
hub_name: str,
endpoint_name: str,
container_name: Optional[str] = None,
endpoint_resource_group: Optional[str] = None,
endpoint_subscription_id: Optional[str] = None,
connection_string: Optional[str] = None,
Expand All @@ -322,7 +319,6 @@ def message_endpoint_update_storage_container(
endpoint_resource_group=endpoint_resource_group,
endpoint_subscription_id=endpoint_subscription_id,
connection_string=connection_string,
container_name=container_name,
batch_frequency=batch_frequency,
chunk_size_window=chunk_size_window,
file_name_format=file_name_format,
Expand Down
22 changes: 12 additions & 10 deletions azext_iot/iothub/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,6 @@ def load_iothub_arguments(self, _):
)

with self.argument_context(f"iot hub message-endpoint {endpoint_op} storage-container") as context:
context.argument(
"container_name",
options_list=["--container-name", "--container"],
help="Name of the storage container.",
)
context.argument(
"batch_frequency",
options_list=["--batch-frequency", "-b"],
Expand Down Expand Up @@ -522,11 +517,6 @@ def load_iothub_arguments(self, _):
options_list=["--database-name", "--db"],
help="The name of the cosmos DB database in the cosmos DB account.",
)
context.argument(
"container_name",
options_list=["--container-name", "--container"],
help="The name of the Cosmos DB SQL Container in the cosmos DB Database.",
)
context.argument(
"primary_key",
options_list=["--primary-key", "--pk"],
Expand Down Expand Up @@ -580,6 +570,18 @@ def load_iothub_arguments(self, _):
arg_type=get_enum_type(EncodingFormat),
help="Encoding format for the container.",
)
context.argument(
"container_name",
options_list=["--container-name", "--container"],
help="Name of the storage container.",
)

with self.argument_context("iot hub message-endpoint create cosmosdb-container") as context:
context.argument(
"container_name",
options_list=["--container-name", "--container"],
help="The name of the Cosmos DB SQL Container in the cosmos DB Database.",
)

with self.argument_context("iot hub message-endpoint update cosmosdb-container") as context:
context.argument(
Expand Down
5 changes: 0 additions & 5 deletions azext_iot/iothub/providers/message_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def update(
endpoint_resource_group: Optional[str] = None,
endpoint_subscription_id: Optional[str] = None,
connection_string: Optional[str] = None,
container_name: Optional[str] = None,
batch_frequency: Optional[int] = None,
chunk_size_window: Optional[int] = None,
file_name_format: Optional[str] = None,
Expand Down Expand Up @@ -305,8 +304,6 @@ def update(
original_endpoint.entity_path = entity_path

if endpoint_type == EndpointType.AzureStorageContainer.value:
if container_name:
original_endpoint.container_name = container_name
if file_name_format:
original_endpoint.file_name_format = file_name_format
if batch_frequency:
Expand All @@ -325,8 +322,6 @@ def update(
original_endpoint.endpoint_uri = parsed_cs["AccountEndpoint"]
if database_name:
original_endpoint.database_name = database_name
if container_name:
original_endpoint.container_name = container_name
if partition_key_name:
original_endpoint.partition_key_name = None if partition_key_name == "" else partition_key_name
if partition_key_template:
Expand Down
Loading

0 comments on commit a5f59de

Please sign in to comment.