diff --git a/azext_edge/edge/_help.py b/azext_edge/edge/_help.py index 945fed1b0..8359d68f9 100644 --- a/azext_edge/edge/_help.py +++ b/azext_edge/edge/_help.py @@ -1029,7 +1029,7 @@ def load_iotops_help(): - name: Create an asset endpoint with username-password user authentication using the given instance in a different resource group but same subscription. The additional configuration is provided as an inline json. text: > - az iot ops asset endpoint create opcua --name myprofile -g myresourcegroup --instance myinstance + az iot ops asset endpoint create custom --name myprofile -g myresourcegroup --instance myinstance --instance-resource-group myinstanceresourcegroup --target-address http://rest-server-service.azure-iot-operations.svc.cluster.local:80 --endpoint-type rest-thermostat --username-ref rest-server-auth-creds/username --password-ref rest-server-auth-creds/password @@ -1051,6 +1051,25 @@ def load_iotops_help(): --additional-configuration '{"hello": "world"}' """ + helps[ + "iot ops asset endpoint create onvif" + ] = """ + type: command + short-summary: Create an asset endpoint profile with an Onvif connector. + long-summary: For more information on how to create an Onvif connector, please see aka.ms/onvif-quickstart + examples: + - name: Create an asset endpoint with anonymous user authentication using the given instance in the same resource group. + text: > + az iot ops asset endpoint create onvif --name myprofile -g myresourcegroup --instance myinstance + --target-address http://onvif-rtsp-simulator:8000 + - name: Create an asset endpoint with username-password user authentication using the given instance in a different resource group but same subscription. + text: > + az iot ops asset endpoint create onvif --name myprofile -g myresourcegroup --instance myinstance + --instance-resource-group myinstanceresourcegroup + --target-address http://onvif-rtsp-simulator:8000 + --username-ref rest-server-auth-creds/username --password-ref rest-server-auth-creds/password + """ + helps[ "iot ops asset endpoint create opcua" ] = """ diff --git a/azext_edge/edge/command_map.py b/azext_edge/edge/command_map.py index 8e273bfac..7bc4ae837 100644 --- a/azext_edge/edge/command_map.py +++ b/azext_edge/edge/command_map.py @@ -164,6 +164,7 @@ def load_iotops_commands(self, _): command_type=aep_resource_ops, ) as cmd_group: cmd_group.command("custom", "create_custom_asset_endpoint_profile") + cmd_group.command("onvif", "create_onvif_asset_endpoint_profile", is_preview=True) cmd_group.command("opcua", "create_opcua_asset_endpoint_profile") with self.command_group( diff --git a/azext_edge/edge/commands_asset_endpoint_profiles.py b/azext_edge/edge/commands_asset_endpoint_profiles.py index 1ab345f15..77104a7d6 100644 --- a/azext_edge/edge/commands_asset_endpoint_profiles.py +++ b/azext_edge/edge/commands_asset_endpoint_profiles.py @@ -14,6 +14,73 @@ logger = get_logger(__name__) +def create_custom_asset_endpoint_profile( + cmd, + asset_endpoint_profile_name: str, + endpoint_profile_type: str, + instance_name: str, + resource_group_name: str, + target_address: str, + certificate_reference: Optional[str] = None, + instance_resource_group: Optional[str] = None, + instance_subscription: Optional[str] = None, + location: Optional[str] = None, + password_reference: Optional[str] = None, + username_reference: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + additional_configuration: Optional[str] = None, + **kwargs +) -> dict: + return AssetEndpointProfiles(cmd).create( + asset_endpoint_profile_name=asset_endpoint_profile_name, + endpoint_profile_type=endpoint_profile_type, + instance_name=instance_name, + resource_group_name=resource_group_name, + target_address=target_address, + certificate_reference=certificate_reference, + instance_resource_group=instance_resource_group, + instance_subscription=instance_subscription, + location=location, + password_reference=password_reference, + username_reference=username_reference, + tags=tags, + additional_configuration=additional_configuration, + **kwargs + ) + + +def create_onvif_asset_endpoint_profile( + cmd, + asset_endpoint_profile_name: str, + instance_name: str, + resource_group_name: str, + target_address: str, + certificate_reference: Optional[str] = None, + instance_resource_group: Optional[str] = None, + instance_subscription: Optional[str] = None, + location: Optional[str] = None, + password_reference: Optional[str] = None, + username_reference: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs +) -> dict: + return AssetEndpointProfiles(cmd).create( + asset_endpoint_profile_name=asset_endpoint_profile_name, + endpoint_profile_type=AEPTypes.onvif.value, + instance_name=instance_name, + resource_group_name=resource_group_name, + target_address=target_address, + certificate_reference=certificate_reference, + instance_resource_group=instance_resource_group, + instance_subscription=instance_subscription, + location=location, + password_reference=password_reference, + username_reference=username_reference, + tags=tags, + **kwargs + ) + + def create_opcua_asset_endpoint_profile( cmd, asset_endpoint_profile_name: str, @@ -76,41 +143,6 @@ def create_opcua_asset_endpoint_profile( ) -def create_custom_asset_endpoint_profile( - cmd, - asset_endpoint_profile_name: str, - endpoint_profile_type: str, - instance_name: str, - resource_group_name: str, - target_address: str, - certificate_reference: Optional[str] = None, - instance_resource_group: Optional[str] = None, - instance_subscription: Optional[str] = None, - location: Optional[str] = None, - password_reference: Optional[str] = None, - username_reference: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - additional_configuration: Optional[str] = None, - **kwargs -) -> dict: - return AssetEndpointProfiles(cmd).create( - asset_endpoint_profile_name=asset_endpoint_profile_name, - endpoint_profile_type=endpoint_profile_type, - instance_name=instance_name, - resource_group_name=resource_group_name, - target_address=target_address, - certificate_reference=certificate_reference, - instance_resource_group=instance_resource_group, - instance_subscription=instance_subscription, - location=location, - password_reference=password_reference, - username_reference=username_reference, - tags=tags, - additional_configuration=additional_configuration, - **kwargs - ) - - def delete_asset_endpoint_profile( cmd, asset_endpoint_profile_name: str, diff --git a/azext_edge/edge/common.py b/azext_edge/edge/common.py index 7e86cf3a5..f53daa462 100644 --- a/azext_edge/edge/common.py +++ b/azext_edge/edge/common.py @@ -204,8 +204,8 @@ class AEPAuthModes(Enum): class AEPTypes(ListableEnum): """Asset Endpoint Profile (connector) Types""" - # TODO: ensure this is the final enum opcua = "Microsoft.OpcUa" + onvif = "Microsoft.Onvif" class TopicRetain(Enum): diff --git a/azext_edge/tests/edge/rpsaas/adr/test_asset_endpoint_profiles_int.py b/azext_edge/tests/edge/rpsaas/adr/test_asset_endpoint_profiles_int.py index 45f31a5de..c98173bd1 100644 --- a/azext_edge/tests/edge/rpsaas/adr/test_asset_endpoint_profiles_int.py +++ b/azext_edge/tests/edge/rpsaas/adr/test_asset_endpoint_profiles_int.py @@ -91,7 +91,7 @@ def test_asset_endpoint_lifecycle(require_init, tracked_resources, tracked_files password = generate_random_string() address = f"opc.tcp://{generate_random_string()}:5000" userpass_endpoint = run( - f"az iot ops asset endpoint create opcua -n {userpass_name} -g {rg} --instance {instance} " + f"az iot ops asset endpoint create onvif -n {userpass_name} -g {rg} --instance {instance} " f"--ta {address} --username-ref {username} --password-ref {password}" ) tracked_resources.append(userpass_endpoint["id"]) @@ -102,7 +102,7 @@ def test_asset_endpoint_lifecycle(require_init, tracked_resources, tracked_files target_address=address, username_reference=username, password_reference=password, - endpoint_type="Microsoft.OpcUa", + endpoint_type="Microsoft.Onvif", ) cert_name = "test-endpoint-" + generate_random_string(force_lower=True)[:4]