diff --git a/HISTORY.rst b/HISTORY.rst index 0127b7937..11790f457 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,20 @@ Release History =============== +0.10.0 ++++++++++++++++ + +**Breaking Changes** + +* `az iot dps enrollment show` and `az iot dps enrollment-group show` now return raw service results instead of deserialized models. + This means that some properties that were previously returned as `null` for these commands will no longer be returned, possibly causing a breaking change. + +**IoT DPS updates** + +* Added --show-keys argument to `dps enrollment show` and `dps enrollment-group show` to include full attestation information for symmetric key enrollments and enrollment groups +* Regenerated 2019-03-31 DPS Service SDK + + 0.9.9 +++++++++++++++ diff --git a/azext_iot/_factory.py b/azext_iot/_factory.py index 286eb0b63..a64cc0901 100644 --- a/azext_iot/_factory.py +++ b/azext_iot/_factory.py @@ -118,7 +118,7 @@ def _get_pnp_runtime_sdk(self): return IotHubGatewayServiceAPIs(credentials=credentials, base_url=self.endpoint) def _get_dps_service_sdk(self): - from azext_iot.sdk.dps import ProvisioningServiceClient + from azext_iot.sdk.dps.service import ProvisioningServiceClient credentials = SasTokenAuthentication( uri=self.sas_uri, diff --git a/azext_iot/_help.py b/azext_iot/_help.py index 7c0ce4185..6fbae8bed 100644 --- a/azext_iot/_help.py +++ b/azext_iot/_help.py @@ -1007,6 +1007,13 @@ ] = """ type: command short-summary: Get device enrollment details in an Azure IoT Hub Device Provisioning Service. + examples: + - name: Basic usage + text: > + az iot dps enrollment show --dps-name {dps_name} -g {resource_group} --enrollment-id {enrollment_id} + - name: Include full attestation information in results for a symmetric key enrollment + text: > + az iot dps enrollment show --dps-name {dps_name} -g {resource_group} --enrollment-id {symmetric_key_enrollment_id} --show-keys """ helps[ @@ -1133,6 +1140,13 @@ ] = """ type: command short-summary: Get the details of an enrollment group in an Azure IoT Hub Device Provisioning Service. + examples: + - name: Basic usage + text: > + az iot dps enrollment-group show --dps-name {dps_name} -g {resource_group} --enrollment-id {enrollment_id} + - name: Include full attestation information in results for a symmetric key enrollment-group + text: > + az iot dps enrollment-group show --dps-name {dps_name} -g {resource_group} --enrollment-id {symmetric_key_enrollment_id} --show-keys """ helps[ diff --git a/azext_iot/_params.py b/azext_iot/_params.py index 698bb8cec..e21213e39 100644 --- a/azext_iot/_params.py +++ b/azext_iot/_params.py @@ -861,6 +861,14 @@ def load_arguments(self, _): "When choosing tpm as attestation type, endorsement key is required.", ) + with self.argument_context("iot dps enrollment show") as context: + context.argument( + "show_keys", + options_list=["--show-keys", "--keys"], + arg_type=get_three_state_flag(), + help="Include attestation keys and information in enrollment results" + ) + with self.argument_context("iot dps enrollment update") as context: context.argument( "endorsement_key", @@ -905,6 +913,14 @@ def load_arguments(self, _): "If attestation with a root CA certificate is desired then a root ca name must be provided.", ) + with self.argument_context("iot dps enrollment-group show") as context: + context.argument( + "show_keys", + options_list=["--show-keys", "--keys"], + arg_type=get_three_state_flag(), + help="Include attestation keys and information in enrollment group results" + ) + with self.argument_context("iot dps registration") as context: context.argument("registration_id", help="ID of device registration") diff --git a/azext_iot/operations/dps.py b/azext_iot/operations/dps.py index b46ef951d..a9962c9a6 100644 --- a/azext_iot/operations/dps.py +++ b/azext_iot/operations/dps.py @@ -18,27 +18,24 @@ from azext_iot.common.utility import compute_device_key from azext_iot.operations.generic import _execute_query from azext_iot._factory import SdkResolver -from azext_iot.sdk.dps.models.individual_enrollment import IndividualEnrollment -from azext_iot.sdk.dps.models.custom_allocation_definition import ( +from azext_iot.sdk.dps.service.models import ( + IndividualEnrollment, CustomAllocationDefinition, -) -from azext_iot.sdk.dps.models.attestation_mechanism import AttestationMechanism -from azext_iot.sdk.dps.models.tpm_attestation import TpmAttestation -from azext_iot.sdk.dps.models.symmetric_key_attestation import SymmetricKeyAttestation -from azext_iot.sdk.dps.models.x509_attestation import X509Attestation -from azext_iot.sdk.dps.models.x509_certificates import X509Certificates -from azext_iot.sdk.dps.models.x509_certificate_with_info import X509CertificateWithInfo -from azext_iot.sdk.dps.models.initial_twin import InitialTwin -from azext_iot.sdk.dps.models.twin_collection import TwinCollection -from azext_iot.sdk.dps.models.initial_twin_properties import InitialTwinProperties -from azext_iot.sdk.dps.models.enrollment_group import EnrollmentGroup -from azext_iot.sdk.dps.models.x509_ca_references import X509CAReferences -from azext_iot.sdk.dps.models.reprovision_policy import ReprovisionPolicy -from azext_iot.sdk.dps.models import DeviceCapabilities -from azext_iot.sdk.dps.models import ( + AttestationMechanism, + TpmAttestation, + SymmetricKeyAttestation, + X509Attestation, + X509Certificates, + X509CertificateWithInfo, + InitialTwin, + TwinCollection, + InitialTwinProperties, + EnrollmentGroup, + X509CAReferences, + ReprovisionPolicy, + DeviceCapabilities, ProvisioningServiceErrorDetailsException, -) # TODO: Regen SDK - +) logger = get_logger(__name__) @@ -47,7 +44,7 @@ def iot_dps_device_enrollment_list(client, dps_name, resource_group_name, top=None): - from azext_iot.sdk.dps.models.query_specification import QuerySpecification + from azext_iot.sdk.dps.service.models.query_specification import QuerySpecification target = get_iot_dps_connection_string(client, dps_name, resource_group_name) @@ -56,19 +53,38 @@ def iot_dps_device_enrollment_list(client, dps_name, resource_group_name, top=No sdk = resolver.get_sdk(SdkType.dps_sdk) query_command = "SELECT *" - query = [QuerySpecification(query_command)] - return _execute_query(query, sdk.device_enrollment.query, top) + query = [QuerySpecification(query=query_command)] + return _execute_query(query, sdk.query_individual_enrollments, top) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) -def iot_dps_device_enrollment_get(client, enrollment_id, dps_name, resource_group_name): +def iot_dps_device_enrollment_get( + client, enrollment_id, dps_name, resource_group_name, show_keys=None +): target = get_iot_dps_connection_string(client, dps_name, resource_group_name) try: resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.device_enrollment.get(enrollment_id) + enrollment = sdk.get_individual_enrollment( + enrollment_id, raw=True + ).response.json() + if show_keys: + enrollment_type = enrollment["attestation"]["type"] + if enrollment_type == AttestationType.symmetricKey.value: + attestation = sdk.get_individual_enrollment_attestation_mechanism( + enrollment_id, raw=True + ).response.json() + enrollment["attestation"] = attestation + else: + logger.warn( + "--show-keys argument was provided, but requested enrollment has an attestation type of '{}'." + " Currently, --show-keys is only supported for symmetric key enrollments".format( + enrollment_type + ) + ) + return enrollment except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -105,7 +121,8 @@ def iot_dps_device_enrollment_create( if not endorsement_key: raise CLIError("Endorsement key is requried") attestation = AttestationMechanism( - AttestationType.tpm.value, TpmAttestation(endorsement_key) + type=AttestationType.tpm.value, + tpm=TpmAttestation(endorsement_key=endorsement_key), ) if attestation_type == AttestationType.x509.value: attestation = _get_attestation_with_x509_client_cert( @@ -113,10 +130,10 @@ def iot_dps_device_enrollment_create( ) if attestation_type == AttestationType.symmetricKey.value: attestation = AttestationMechanism( - AttestationType.symmetricKey.value, - None, - None, - SymmetricKeyAttestation(primary_key, secondary_key), + type=AttestationType.symmetricKey.value, + symmetric_key=SymmetricKeyAttestation( + primary_key=primary_key, secondary_key=secondary_key + ), ) reprovision = _get_reprovision_policy(reprovision_policy) initial_twin = _get_initial_twin(initial_twin_tags, initial_twin_properties) @@ -129,26 +146,24 @@ def iot_dps_device_enrollment_create( iot_hub_list = iot_hub_host_name.split() custom_allocation_definition = ( - CustomAllocationDefinition(webhook_url, api_version) + CustomAllocationDefinition(webhook_url=webhook_url, api_version=api_version) if allocation_policy == AllocationType.custom.value else None ) capabilities = DeviceCapabilities(iot_edge=edge_enabled) enrollment = IndividualEnrollment( - enrollment_id, - attestation, - capabilities, - device_id, - None, - initial_twin, - None, - provisioning_status, - reprovision, - allocation_policy, - iot_hub_list, - custom_allocation_definition, + registration_id=enrollment_id, + attestation=attestation, + capabilities=capabilities, + device_id=device_id, + initial_twin=initial_twin, + provisioning_status=provisioning_status, + reprovision_policy=reprovision, + allocation_policy=allocation_policy, + iot_hubs=iot_hub_list, + custom_allocation_definition=custom_allocation_definition, ) - return sdk.device_enrollment.create_or_update(enrollment_id, enrollment) + return sdk.create_or_update_individual_enrollment(enrollment_id, enrollment) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -183,7 +198,7 @@ def iot_dps_device_enrollment_update( resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - enrollment_record = sdk.device_enrollment.get(enrollment_id) + enrollment_record = sdk.get_individual_enrollment(enrollment_id) # Verify etag if ( etag @@ -217,7 +232,7 @@ def iot_dps_device_enrollment_update( remove_secondary_certificate, ) else: - enrollment_record.attestation = sdk.device_enrollment.attestation_mechanism_method( + enrollment_record.attestation = sdk.get_individual_enrollment_attestation_mechanism( enrollment_id ) if primary_key: @@ -253,12 +268,12 @@ def iot_dps_device_enrollment_update( enrollment_record.iot_hub_host_name = None if allocation_policy == AllocationType.custom.value: enrollment_record.custom_allocation_definition = CustomAllocationDefinition( - webhook_url, api_version + webhook_url=webhook_url, api_version=api_version ) if edge_enabled is not None: enrollment_record.capabilities = DeviceCapabilities(iot_edge=edge_enabled) - return sdk.device_enrollment.create_or_update( + return sdk.create_or_update_individual_enrollment( enrollment_id, enrollment_record, etag ) except ProvisioningServiceErrorDetailsException as e: @@ -273,7 +288,7 @@ def iot_dps_device_enrollment_delete( resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.device_enrollment.delete(enrollment_id) + return sdk.delete_individual_enrollment(enrollment_id) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -284,7 +299,7 @@ def iot_dps_device_enrollment_delete( def iot_dps_device_enrollment_group_list( client, dps_name, resource_group_name, top=None ): - from azext_iot.sdk.dps.models.query_specification import QuerySpecification + from azext_iot.sdk.dps.service.models.query_specification import QuerySpecification target = get_iot_dps_connection_string(client, dps_name, resource_group_name) try: @@ -292,21 +307,38 @@ def iot_dps_device_enrollment_group_list( sdk = resolver.get_sdk(SdkType.dps_sdk) query_command = "SELECT *" - query1 = [QuerySpecification(query_command)] - return _execute_query(query1, sdk.device_enrollment_group.query, top) + query1 = [QuerySpecification(query=query_command)] + return _execute_query(query1, sdk.query_enrollment_groups, top) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) def iot_dps_device_enrollment_group_get( - client, enrollment_id, dps_name, resource_group_name + client, enrollment_id, dps_name, resource_group_name, show_keys=None ): target = get_iot_dps_connection_string(client, dps_name, resource_group_name) try: resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.device_enrollment_group.get(enrollment_id) + enrollment_group = sdk.get_enrollment_group( + enrollment_id, raw=True + ).response.json() + if show_keys: + enrollment_type = enrollment_group["attestation"]["type"] + if enrollment_type == AttestationType.symmetricKey.value: + attestation = sdk.get_enrollment_group_attestation_mechanism( + enrollment_id, raw=True + ).response.json() + enrollment_group["attestation"] = attestation + else: + logger.warn( + "--show-keys argument was provided, but requested enrollment group has an attestation type of '{}'." + " Currently, --show-keys is only supported for symmetric key enrollment groups".format( + enrollment_type + ) + ) + return enrollment_group except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -341,10 +373,10 @@ def iot_dps_device_enrollment_group_create( if not certificate_path and not secondary_certificate_path: if not root_ca_name and not secondary_root_ca_name: attestation = AttestationMechanism( - AttestationType.symmetricKey.value, - None, - None, - SymmetricKeyAttestation(primary_key, secondary_key), + type=AttestationType.symmetricKey.value, + symmetric_key=SymmetricKeyAttestation( + primary_key=primary_key, secondary_key=secondary_key + ), ) if certificate_path or secondary_certificate_path: if root_ca_name or secondary_root_ca_name: @@ -373,28 +405,24 @@ def iot_dps_device_enrollment_group_create( iot_hub_list = iot_hub_host_name.split() custom_allocation_definition = ( - CustomAllocationDefinition(webhook_url, api_version) + CustomAllocationDefinition(webhook_url=webhook_url, api_version=api_version) if allocation_policy == AllocationType.custom.value else None ) capabilities = DeviceCapabilities(iot_edge=edge_enabled) group_enrollment = EnrollmentGroup( - enrollment_id, - attestation, - capabilities, - None, - initial_twin, - None, - provisioning_status, - reprovision, - allocation_policy, - iot_hub_list, - custom_allocation_definition, - ) - return sdk.device_enrollment_group.create_or_update( - enrollment_id, group_enrollment + enrollment_group_id=enrollment_id, + attestation=attestation, + capabilities=capabilities, + initial_twin=initial_twin, + provisioning_status=provisioning_status, + reprovision_policy=reprovision, + allocation_policy=allocation_policy, + iot_hubs=iot_hub_list, + custom_allocation_definition=custom_allocation_definition, ) + return sdk.create_or_update_enrollment_group(enrollment_id, group_enrollment) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -429,7 +457,7 @@ def iot_dps_device_enrollment_group_update( resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - enrollment_record = sdk.device_enrollment_group.get(enrollment_id) + enrollment_record = sdk.get_enrollment_group(enrollment_id) # Verify etag if ( etag @@ -441,7 +469,7 @@ def iot_dps_device_enrollment_group_update( etag = enrollment_record.etag.replace('"', "") # Update enrollment information if enrollment_record.attestation.type == AttestationType.symmetricKey.value: - enrollment_record.attestation = sdk.device_enrollment_group.attestation_mechanism_method( + enrollment_record.attestation = sdk.get_enrollment_group_attestation_mechanism( enrollment_id ) if primary_key: @@ -519,11 +547,11 @@ def iot_dps_device_enrollment_group_update( enrollment_record.iot_hub_host_name = None if allocation_policy == AllocationType.custom.value: enrollment_record.custom_allocation_definition = CustomAllocationDefinition( - webhook_url, api_version + webhook_url=webhook_url, api_version=api_version ) if edge_enabled is not None: enrollment_record.capabilities = DeviceCapabilities(iot_edge=edge_enabled) - return sdk.device_enrollment_group.create_or_update( + return sdk.create_or_update_enrollment_group( enrollment_id, enrollment_record, etag ) except ProvisioningServiceErrorDetailsException as e: @@ -538,7 +566,7 @@ def iot_dps_device_enrollment_group_delete( resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.device_enrollment_group.delete(enrollment_id) + return sdk.delete_enrollment_group(enrollment_id) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -560,7 +588,9 @@ def iot_dps_registration_list(client, dps_name, resource_group_name, enrollment_ resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.registration_state.query_registration_state(enrollment_id) + return sdk.query_device_registration_states( + enrollment_id, raw=True + ).response.json() except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -571,7 +601,9 @@ def iot_dps_registration_get(client, dps_name, resource_group_name, registration resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.registration_state.get_registration_state(registration_id) + return sdk.get_device_registration_state( + registration_id, raw=True + ).response.json() except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -582,7 +614,7 @@ def iot_dps_registration_delete(client, dps_name, resource_group_name, registrat resolver = SdkResolver(target=target) sdk = resolver.get_sdk(SdkType.dps_sdk) - return sdk.registration_state.delete_registration_state(registration_id) + return sdk.delete_device_registration_state(registration_id) except ProvisioningServiceErrorDetailsException as e: raise CLIError(e) @@ -601,9 +633,12 @@ def _get_initial_twin(initial_twin_tags=None, initial_twin_properties=None): initial_twin_properties = dict_clean( shell_safe_json_parse(str(initial_twin_properties)) ) + return InitialTwin( - TwinCollection(initial_twin_tags), - InitialTwinProperties(TwinCollection(initial_twin_properties)), + tags=TwinCollection(additional_properties=initial_twin_tags), + properties=InitialTwinProperties( + desired=TwinCollection(additional_properties=initial_twin_properties) + ), ) @@ -626,8 +661,8 @@ def _get_updated_inital_twin( def _get_x509_certificate(certificate_path, secondary_certificate_path): x509certificate = X509Certificates( - _get_certificate_info(certificate_path), - _get_certificate_info(secondary_certificate_path), + primary=_get_certificate_info(certificate_path), + secondary=_get_certificate_info(secondary_certificate_path), ) return x509certificate @@ -636,7 +671,7 @@ def _get_certificate_info(certificate_path): if not certificate_path: return None certificate_content = open_certificate(certificate_path) - certificate_with_info = X509CertificateWithInfo(certificate_content) + certificate_with_info = X509CertificateWithInfo(certificate=certificate_content) return certificate_with_info @@ -648,9 +683,9 @@ def _get_attestation_with_x509_client_cert( certificate = _get_x509_certificate( primary_certificate_path, secondary_certificate_path ) - x509Attestation = X509Attestation(certificate) + x509Attestation = X509Attestation(client_certificates=certificate) attestation = AttestationMechanism( - AttestationType.x509.value, None, x509Attestation + type=AttestationType.x509.value, x509=x509Attestation ) return attestation @@ -683,18 +718,20 @@ def _get_attestation_with_x509_signing_cert( certificate = _get_x509_certificate( primary_certificate_path, secondary_certificate_path ) - x509Attestation = X509Attestation(None, certificate) + x509Attestation = X509Attestation(signing_certificates=certificate) attestation = AttestationMechanism( - AttestationType.x509.value, None, x509Attestation + type=AttestationType.x509.value, x509=x509Attestation ) return attestation def _get_attestation_with_x509_ca_cert(root_ca_name, secondary_root_ca_name): - certificate = X509CAReferences(root_ca_name, secondary_root_ca_name) - x509Attestation = X509Attestation(None, None, certificate) + certificate = X509CAReferences( + primary=root_ca_name, secondary=secondary_root_ca_name + ) + x509Attestation = X509Attestation(ca_references=certificate) attestation = AttestationMechanism( - AttestationType.x509.value, None, x509Attestation + type=AttestationType.x509.value, x509=x509Attestation ) return attestation @@ -785,15 +822,23 @@ def _can_remove_secondary_certificate(remove_certificate, attestation): def _get_reprovision_policy(reprovision_policy): if reprovision_policy: if reprovision_policy == ReprovisionType.reprovisionandmigratedata.value: - reprovision = ReprovisionPolicy(True, True) + reprovision = ReprovisionPolicy( + update_hub_assignment=True, migrate_device_data=True + ) elif reprovision_policy == ReprovisionType.reprovisionandresetdata.value: - reprovision = ReprovisionPolicy(True, False) + reprovision = ReprovisionPolicy( + update_hub_assignment=True, migrate_device_data=False + ) elif reprovision_policy == ReprovisionType.never.value: - reprovision = ReprovisionPolicy(False, False) + reprovision = ReprovisionPolicy( + update_hub_assignment=False, migrate_device_data=False + ) else: raise CLIError("Invalid Reprovision Policy.") else: - reprovision = ReprovisionPolicy(True, True) + reprovision = ReprovisionPolicy( + update_hub_assignment=True, migrate_device_data=True + ) return reprovision diff --git a/azext_iot/sdk/dps/__init__.py b/azext_iot/sdk/dps/__init__.py index 7cc65f931..55614acbf 100644 --- a/azext_iot/sdk/dps/__init__.py +++ b/azext_iot/sdk/dps/__init__.py @@ -1,14 +1,5 @@ # coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .provisioning_service_client import ProvisioningServiceClient -from .version import VERSION - -__all__ = ['ProvisioningServiceClient'] - -__version__ = VERSION - +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- diff --git a/azext_iot/sdk/dps/models/__init__.py b/azext_iot/sdk/dps/models/__init__.py deleted file mode 100644 index 0c8326d2e..000000000 --- a/azext_iot/sdk/dps/models/__init__.py +++ /dev/null @@ -1,58 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .provisioning_service_error_details import ProvisioningServiceErrorDetails, ProvisioningServiceErrorDetailsException -from .device_capabilities import DeviceCapabilities -from .individual_enrollment_registration_state import IndividualEnrollmentRegistrationState -from .tpm_attestation import TpmAttestation -from .x509_certificate_info import X509CertificateInfo -from .x509_certificate_with_info import X509CertificateWithInfo -from .x509_certificates import X509Certificates -from .x509_ca_references import X509CAReferences -from .x509_attestation import X509Attestation -from .symmetric_key_attestation import SymmetricKeyAttestation -from .attestation_mechanism import AttestationMechanism -from .metadata import Metadata -from .twin_collection import TwinCollection -from .initial_twin_properties import InitialTwinProperties -from .initial_twin import InitialTwin -from .reprovision_policy import ReprovisionPolicy -from .custom_allocation_definition import CustomAllocationDefinition -from .individual_enrollment import IndividualEnrollment -from .device_registration_state import DeviceRegistrationState -from .enrollment_group import EnrollmentGroup -from .bulk_enrollment_operation import BulkEnrollmentOperation -from .bulk_enrollment_operation_error import BulkEnrollmentOperationError -from .bulk_enrollment_operation_result import BulkEnrollmentOperationResult -from .query_specification import QuerySpecification - -__all__ = [ - 'ProvisioningServiceErrorDetails', 'ProvisioningServiceErrorDetailsException', - 'DeviceCapabilities', - 'IndividualEnrollmentRegistrationState', - 'TpmAttestation', - 'X509CertificateInfo', - 'X509CertificateWithInfo', - 'X509Certificates', - 'X509CAReferences', - 'X509Attestation', - 'SymmetricKeyAttestation', - 'AttestationMechanism', - 'Metadata', - 'TwinCollection', - 'InitialTwinProperties', - 'InitialTwin', - 'ReprovisionPolicy', - 'CustomAllocationDefinition', - 'IndividualEnrollment', - 'DeviceRegistrationState', - 'EnrollmentGroup', - 'BulkEnrollmentOperation', - 'BulkEnrollmentOperationError', - 'BulkEnrollmentOperationResult', - 'QuerySpecification', -] diff --git a/azext_iot/sdk/dps/operations/__init__.py b/azext_iot/sdk/dps/operations/__init__.py deleted file mode 100644 index 54916bd89..000000000 --- a/azext_iot/sdk/dps/operations/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from .device_enrollment_operations import DeviceEnrollmentOperations -from .device_enrollment_group_operations import DeviceEnrollmentGroupOperations -from .registration_state_operations import RegistrationStateOperations - -__all__ = [ - 'DeviceEnrollmentOperations', - 'DeviceEnrollmentGroupOperations', - 'RegistrationStateOperations', -] diff --git a/azext_iot/sdk/dps/operations/device_enrollment_group_operations.py b/azext_iot/sdk/dps/operations/device_enrollment_group_operations.py deleted file mode 100644 index 2ada50461..000000000 --- a/azext_iot/sdk/dps/operations/device_enrollment_group_operations.py +++ /dev/null @@ -1,347 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -import uuid -from msrest.pipeline import ClientRawResponse - -from .. import models - - -class DeviceEnrollmentGroupOperations(object): - """DeviceEnrollmentGroupOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the request. Supported versions include: 2018-09-01-preview. Constant value: "2018-09-01-preview". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-03-31" - - self.config = config - - def get( - self, id, custom_headers=None, raw=False, **operation_config): - """Get a device enrollment group. - - :param id: Enrollment group ID. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: EnrollmentGroup or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.EnrollmentGroup - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('EnrollmentGroup', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/enrollmentGroups/{id}'} - - def create_or_update( - self, id, enrollment_group, if_match=None, custom_headers=None, raw=False, **operation_config): - """Create or update a device enrollment group. - - :param id: Enrollment group ID. - :type id: str - :param enrollment_group: The device enrollment group. - :type enrollment_group: - ~microsoft.azure.management.provisioningservices.models.EnrollmentGroup - :param if_match: The ETag of the enrollment record. - :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: EnrollmentGroup or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.EnrollmentGroup - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.create_or_update.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(enrollment_group, 'EnrollmentGroup') - - # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('EnrollmentGroup', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - create_or_update.metadata = {'url': '/enrollmentGroups/{id}'} - - def delete( - self, id, if_match=None, custom_headers=None, raw=False, **operation_config): - """Delete a device enrollment group. - - :param id: Enrollment group ID. - :type id: str - :param if_match: The ETag of the enrollment group record. - :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.delete.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [204]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/enrollmentGroups/{id}'} - - def query( - self, query_specification, x_ms_max_item_count=None, x_ms_continuation=None, custom_headers=None, raw=False, **operation_config): - """Query the device enrollment groups. - - :param query_specification: The query specification. - :type query_specification: - ~microsoft.azure.management.provisioningservices.models.QuerySpecification - :param x_ms_max_item_count: pageSize - :type x_ms_max_item_count: int - :param x_ms_continuation: continuation token - :type x_ms_continuation: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: - list[~microsoft.azure.management.provisioningservices.models.EnrollmentGroup] - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.query.metadata['url'] - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if x_ms_max_item_count is not None: - header_parameters['x-ms-max-item-count'] = self._serialize.header("x_ms_max_item_count", x_ms_max_item_count, 'int') - if x_ms_continuation is not None: - header_parameters['x-ms-continuation'] = self._serialize.header("x_ms_continuation", x_ms_continuation, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(query_specification, 'QuerySpecification') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - header_dict = {} - - if response.status_code == 200: - deserialized = self._deserialize('[EnrollmentGroup]', response) - header_dict = { - 'x-ms-continuation': 'str', - 'x-ms-max-item-count': 'int', - 'x-ms-item-type': 'str', - } - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - - # Added Custom - continuation = response.headers.get('x-ms-continuation') - - return deserialized, continuation - query.metadata = {'url': '/enrollmentGroups/query'} - - def attestation_mechanism_method( - self, id, custom_headers=None, raw=False, **operation_config): - """Get the attestation mechanism in the device enrollment group record. - - :param id: Enrollment group ID - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AttestationMechanism or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.AttestationMechanism - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.attestation_mechanism_method.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('AttestationMechanism', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - attestation_mechanism_method.metadata = {'url': '/enrollmentGroups/{id}/attestationmechanism'} diff --git a/azext_iot/sdk/dps/operations/device_enrollment_operations.py b/azext_iot/sdk/dps/operations/device_enrollment_operations.py deleted file mode 100644 index 277d7c626..000000000 --- a/azext_iot/sdk/dps/operations/device_enrollment_operations.py +++ /dev/null @@ -1,409 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse - -from .. import models - - -class DeviceEnrollmentOperations(object): - """DeviceEnrollmentOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the request. Supported versions include: 2018-09-01-preview. Constant value: "2018-09-01-preview". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-03-31" - - self.config = config - - def get( - self, id, custom_headers=None, raw=False, **operation_config): - """Get a device enrollment record. - - :param id: Registration ID. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IndividualEnrollment or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.IndividualEnrollment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('IndividualEnrollment', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/enrollments/{id}'} - - def create_or_update( - self, id, enrollment, if_match=None, custom_headers=None, raw=False, **operation_config): - """Create or update a device enrollment record. - - :param id: The registration ID is alphanumeric, lowercase, and may - contain hyphens. - :type id: str - :param enrollment: The device enrollment record. - :type enrollment: - ~microsoft.azure.management.provisioningservices.models.IndividualEnrollment - :param if_match: The ETag of the enrollment record. - :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IndividualEnrollment or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.IndividualEnrollment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.create_or_update.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(enrollment, 'IndividualEnrollment') - - # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('IndividualEnrollment', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - create_or_update.metadata = {'url': '/enrollments/{id}'} - - def delete( - self, id, if_match=None, custom_headers=None, raw=False, **operation_config): - """Delete a device enrollment record. - - :param id: Registration ID. - :type id: str - :param if_match: The ETag of the enrollment record. - :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.delete.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [204]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/enrollments/{id}'} - - def bulk_operation( - self, bulk_operation, custom_headers=None, raw=False, **operation_config): - """Bulk device enrollment operation. - - :param bulk_operation: Bulk operation. - :type bulk_operation: - ~microsoft.azure.management.provisioningservices.models.BulkEnrollmentOperation - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: BulkEnrollmentOperationResult or ClientRawResponse if - raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.BulkEnrollmentOperationResult - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.bulk_operation.metadata['url'] - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(bulk_operation, 'BulkEnrollmentOperation') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('BulkEnrollmentOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - bulk_operation.metadata = {'url': '/enrollments'} - - def query( - self, query_specification, x_ms_max_item_count=None, x_ms_continuation=None, custom_headers=None, raw=False, **operation_config): - """Query the device enrollment records. - - :param query_specification: The query specification. - :type query_specification: - ~microsoft.azure.management.provisioningservices.models.QuerySpecification - :param x_ms_max_item_count: pageSize - :type x_ms_max_item_count: int - :param x_ms_continuation: continuation token - :type x_ms_continuation: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: - list[~microsoft.azure.management.provisioningservices.models.IndividualEnrollment] - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.query.metadata['url'] - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if x_ms_max_item_count is not None: - header_parameters['x-ms-max-item-count'] = self._serialize.header("x_ms_max_item_count", x_ms_max_item_count, 'int') - if x_ms_continuation is not None: - header_parameters['x-ms-continuation'] = self._serialize.header("x_ms_continuation", x_ms_continuation, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(query_specification, 'QuerySpecification') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - header_dict = {} - - if response.status_code == 200: - deserialized = self._deserialize('[IndividualEnrollment]', response) - header_dict = { - 'x-ms-continuation': 'str', - 'x-ms-max-item-count': 'int', - 'x-ms-item-type': 'str', - } - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - - # Added Custom - continuation = response.headers.get('x-ms-continuation') - - return deserialized, continuation - query.metadata = {'url': '/enrollments/query'} - - def attestation_mechanism_method( - self, id, custom_headers=None, raw=False, **operation_config): - """Get the attestation mechanism in the device enrollment record. - - :param id: Registration ID. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AttestationMechanism or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.AttestationMechanism - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.attestation_mechanism_method.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('AttestationMechanism', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - attestation_mechanism_method.metadata = {'url': '/enrollments/{id}/attestationmechanism'} diff --git a/azext_iot/sdk/dps/operations/registration_state_operations.py b/azext_iot/sdk/dps/operations/registration_state_operations.py deleted file mode 100644 index c74ecca7e..000000000 --- a/azext_iot/sdk/dps/operations/registration_state_operations.py +++ /dev/null @@ -1,202 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse - -from .. import models - - -class RegistrationStateOperations(object): - """RegistrationStateOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the request. Supported versions include: 2018-09-01-preview. Constant value: "2018-09-01-preview". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-03-31" - - self.config = config - - def get_registration_state( - self, id, custom_headers=None, raw=False, **operation_config): - """Gets the device registration state. - - :param id: Registration ID. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeviceRegistrationState or ClientRawResponse if raw=true - :rtype: - ~microsoft.azure.management.provisioningservices.models.DeviceRegistrationState - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.get_registration_state.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('DeviceRegistrationState', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_registration_state.metadata = {'url': '/registrations/{id}'} - - def delete_registration_state( - self, id, if_match=None, custom_headers=None, raw=False, **operation_config): - """Deletes the device registration. - - :param id: Registration ID. - :type id: str - :param if_match: The ETag of the registration status record. - :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.delete_registration_state.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [204]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_registration_state.metadata = {'url': '/registrations/{id}'} - - def query_registration_state( - self, id, custom_headers=None, raw=False, **operation_config): - """Gets the registration state of devices in this enrollmentGroup. - - :param id: Enrollment group ID. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: - list[~microsoft.azure.management.provisioningservices.models.DeviceRegistrationState] - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ProvisioningServiceErrorDetailsException` - """ - # Construct URL - url = self.query_registration_state.metadata['url'] - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('[DeviceRegistrationState]', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - query_registration_state.metadata = {'url': '/registrations/{id}/query'} diff --git a/azext_iot/sdk/dps/provisioning_service_client.py b/azext_iot/sdk/dps/provisioning_service_client.py deleted file mode 100644 index ffeae8354..000000000 --- a/azext_iot/sdk/dps/provisioning_service_client.py +++ /dev/null @@ -1,80 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.service_client import ServiceClient -from msrest import Serializer, Deserializer -from msrestazure import AzureConfiguration -from .version import VERSION -from .operations.device_enrollment_operations import DeviceEnrollmentOperations -from .operations.device_enrollment_group_operations import DeviceEnrollmentGroupOperations -from .operations.registration_state_operations import RegistrationStateOperations -from . import models -from azext_iot.constants import USER_AGENT - - -class ProvisioningServiceClientConfiguration(AzureConfiguration): - """Configuration for ProvisioningServiceClient - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://localhost' - - super(ProvisioningServiceClientConfiguration, self).__init__(base_url) - self.add_user_agent('provisioningserviceclient/{}'.format(VERSION)) - self.add_user_agent(USER_AGENT) - - self.credentials = credentials - - -class ProvisioningServiceClient(object): - """API for service operations with the Azure IoT Hub Device Provisioning Service - - :ivar config: Configuration for client. - :vartype config: ProvisioningServiceClientConfiguration - - :ivar device_enrollment: DeviceEnrollment operations - :vartype device_enrollment: microsoft.azure.management.provisioningservices.operations.DeviceEnrollmentOperations - :ivar device_enrollment_group: DeviceEnrollmentGroup operations - :vartype device_enrollment_group: microsoft.azure.management.provisioningservices.operations.DeviceEnrollmentGroupOperations - :ivar registration_state: RegistrationState operations - :vartype registration_state: microsoft.azure.management.provisioningservices.operations.RegistrationStateOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): - - self.config = ProvisioningServiceClientConfiguration(credentials, base_url) - self._client = ServiceClient(self.config.credentials, self.config) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2019-03-31' # @digimaun - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.device_enrollment = DeviceEnrollmentOperations( - self._client, self.config, self._serialize, self._deserialize) - self.device_enrollment_group = DeviceEnrollmentGroupOperations( - self._client, self.config, self._serialize, self._deserialize) - self.registration_state = RegistrationStateOperations( - self._client, self.config, self._serialize, self._deserialize) diff --git a/azext_iot/sdk/dps/service/__init__.py b/azext_iot/sdk/dps/service/__init__.py new file mode 100644 index 000000000..a2cf0b44c --- /dev/null +++ b/azext_iot/sdk/dps/service/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .provisioning_service_client import ProvisioningServiceClient +from .version import VERSION + +__all__ = ['ProvisioningServiceClient'] + +__version__ = VERSION + diff --git a/azext_iot/sdk/dps/service/models/__init__.py b/azext_iot/sdk/dps/service/models/__init__.py new file mode 100644 index 000000000..96dff47da --- /dev/null +++ b/azext_iot/sdk/dps/service/models/__init__.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from .device_registration_state_py3 import DeviceRegistrationState + from .tpm_attestation_py3 import TpmAttestation + from .x509_certificate_info_py3 import X509CertificateInfo + from .x509_certificate_with_info_py3 import X509CertificateWithInfo + from .x509_certificates_py3 import X509Certificates + from .x509_ca_references_py3 import X509CAReferences + from .x509_attestation_py3 import X509Attestation + from .symmetric_key_attestation_py3 import SymmetricKeyAttestation + from .attestation_mechanism_py3 import AttestationMechanism + from .device_capabilities_py3 import DeviceCapabilities + from .metadata_py3 import Metadata + from .twin_collection_py3 import TwinCollection + from .initial_twin_properties_py3 import InitialTwinProperties + from .initial_twin_py3 import InitialTwin + from .reprovision_policy_py3 import ReprovisionPolicy + from .custom_allocation_definition_py3 import CustomAllocationDefinition + from .individual_enrollment_py3 import IndividualEnrollment + from .enrollment_group_py3 import EnrollmentGroup + from .provisioning_service_error_details_py3 import ProvisioningServiceErrorDetails, ProvisioningServiceErrorDetailsException + from .query_specification_py3 import QuerySpecification + from .bulk_enrollment_operation_py3 import BulkEnrollmentOperation + from .bulk_enrollment_operation_error_py3 import BulkEnrollmentOperationError + from .bulk_enrollment_operation_result_py3 import BulkEnrollmentOperationResult + from .bulk_enrollment_group_operation_py3 import BulkEnrollmentGroupOperation + from .bulk_enrollment_group_operation_error_py3 import BulkEnrollmentGroupOperationError + from .bulk_enrollment_group_operation_result_py3 import BulkEnrollmentGroupOperationResult +except (SyntaxError, ImportError): + from .device_registration_state import DeviceRegistrationState + from .tpm_attestation import TpmAttestation + from .x509_certificate_info import X509CertificateInfo + from .x509_certificate_with_info import X509CertificateWithInfo + from .x509_certificates import X509Certificates + from .x509_ca_references import X509CAReferences + from .x509_attestation import X509Attestation + from .symmetric_key_attestation import SymmetricKeyAttestation + from .attestation_mechanism import AttestationMechanism + from .device_capabilities import DeviceCapabilities + from .metadata import Metadata + from .twin_collection import TwinCollection + from .initial_twin_properties import InitialTwinProperties + from .initial_twin import InitialTwin + from .reprovision_policy import ReprovisionPolicy + from .custom_allocation_definition import CustomAllocationDefinition + from .individual_enrollment import IndividualEnrollment + from .enrollment_group import EnrollmentGroup + from .provisioning_service_error_details import ProvisioningServiceErrorDetails, ProvisioningServiceErrorDetailsException + from .query_specification import QuerySpecification + from .bulk_enrollment_operation import BulkEnrollmentOperation + from .bulk_enrollment_operation_error import BulkEnrollmentOperationError + from .bulk_enrollment_operation_result import BulkEnrollmentOperationResult + from .bulk_enrollment_group_operation import BulkEnrollmentGroupOperation + from .bulk_enrollment_group_operation_error import BulkEnrollmentGroupOperationError + from .bulk_enrollment_group_operation_result import BulkEnrollmentGroupOperationResult + +__all__ = [ + 'DeviceRegistrationState', + 'TpmAttestation', + 'X509CertificateInfo', + 'X509CertificateWithInfo', + 'X509Certificates', + 'X509CAReferences', + 'X509Attestation', + 'SymmetricKeyAttestation', + 'AttestationMechanism', + 'DeviceCapabilities', + 'Metadata', + 'TwinCollection', + 'InitialTwinProperties', + 'InitialTwin', + 'ReprovisionPolicy', + 'CustomAllocationDefinition', + 'IndividualEnrollment', + 'EnrollmentGroup', + 'ProvisioningServiceErrorDetails', 'ProvisioningServiceErrorDetailsException', + 'QuerySpecification', + 'BulkEnrollmentOperation', + 'BulkEnrollmentOperationError', + 'BulkEnrollmentOperationResult', + 'BulkEnrollmentGroupOperation', + 'BulkEnrollmentGroupOperationError', + 'BulkEnrollmentGroupOperationResult', +] diff --git a/azext_iot/sdk/dps/service/models/attestation_mechanism.py b/azext_iot/sdk/dps/service/models/attestation_mechanism.py new file mode 100644 index 000000000..d31e8ab0e --- /dev/null +++ b/azext_iot/sdk/dps/service/models/attestation_mechanism.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AttestationMechanism(Model): + """Attestation mechanism for individualEnrollment as well as enrollmentGroup. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Attestation Type. Possible values include: 'none', + 'tpm', 'x509', 'symmetricKey' + :type type: str or ~dps.models.enum + :param tpm: TPM attestation method. + :type tpm: ~dps.models.TpmAttestation + :param x509: X509 attestation method. + :type x509: ~dps.models.X509Attestation + :param symmetric_key: Symmetric Key attestation method. + :type symmetric_key: ~dps.models.SymmetricKeyAttestation + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'tpm': {'key': 'tpm', 'type': 'TpmAttestation'}, + 'x509': {'key': 'x509', 'type': 'X509Attestation'}, + 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKeyAttestation'}, + } + + def __init__(self, **kwargs): + super(AttestationMechanism, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.tpm = kwargs.get('tpm', None) + self.x509 = kwargs.get('x509', None) + self.symmetric_key = kwargs.get('symmetric_key', None) diff --git a/azext_iot/sdk/dps/models/attestation_mechanism.py b/azext_iot/sdk/dps/service/models/attestation_mechanism_py3.py similarity index 61% rename from azext_iot/sdk/dps/models/attestation_mechanism.py rename to azext_iot/sdk/dps/service/models/attestation_mechanism_py3.py index dca688476..299119c80 100644 --- a/azext_iot/sdk/dps/models/attestation_mechanism.py +++ b/azext_iot/sdk/dps/service/models/attestation_mechanism_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,19 +15,17 @@ class AttestationMechanism(Model): """Attestation mechanism for individualEnrollment as well as enrollmentGroup. - :param type: Attestation Type. Possible values include: 'none', 'tpm', - 'x509', 'symmetricKey' - :type type: str or - ~microsoft.azure.management.provisioningservices.models.enum + All required parameters must be populated in order to send to Azure. + + :param type: Required. Attestation Type. Possible values include: 'none', + 'tpm', 'x509', 'symmetricKey' + :type type: str or ~dps.models.enum :param tpm: TPM attestation method. - :type tpm: - ~microsoft.azure.management.provisioningservices.models.TpmAttestation + :type tpm: ~dps.models.TpmAttestation :param x509: X509 attestation method. - :type x509: - ~microsoft.azure.management.provisioningservices.models.X509Attestation + :type x509: ~dps.models.X509Attestation :param symmetric_key: Symmetric Key attestation method. - :type symmetric_key: - ~microsoft.azure.management.provisioningservices.models.SymmetricKeyAttestation + :type symmetric_key: ~dps.models.SymmetricKeyAttestation """ _validation = { @@ -37,8 +39,8 @@ class AttestationMechanism(Model): 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKeyAttestation'}, } - def __init__(self, type, tpm=None, x509=None, symmetric_key=None): - super(AttestationMechanism, self).__init__() + def __init__(self, *, type, tpm=None, x509=None, symmetric_key=None, **kwargs) -> None: + super(AttestationMechanism, self).__init__(**kwargs) self.type = type self.tpm = tpm self.x509 = x509 diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation.py new file mode 100644 index 000000000..70279cdfb --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentGroupOperation(Model): + """Bulk enrollment operation. + + All required parameters must be populated in order to send to Azure. + + :param enrollment_groups: Required. Enrollment items + :type enrollment_groups: list[~dps.models.EnrollmentGroup] + :param mode: Required. Operation mode. Possible values include: 'create', + 'update', 'updateIfMatchETag', 'delete' + :type mode: str or ~dps.models.enum + """ + + _validation = { + 'enrollment_groups': {'required': True}, + 'mode': {'required': True}, + } + + _attribute_map = { + 'enrollment_groups': {'key': 'enrollmentGroups', 'type': '[EnrollmentGroup]'}, + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(BulkEnrollmentGroupOperation, self).__init__(**kwargs) + self.enrollment_groups = kwargs.get('enrollment_groups', None) + self.mode = kwargs.get('mode', None) diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_error.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_error.py new file mode 100644 index 000000000..11c583c4d --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_error.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentGroupOperationError(Model): + """Bulk enrollment operation error. + + All required parameters must be populated in order to send to Azure. + + :param enrollment_group_id: Required. Enrollment group id. + :type enrollment_group_id: str + :param error_code: Required. Error code + :type error_code: int + :param error_status: Required. Error status. + :type error_status: str + """ + + _validation = { + 'enrollment_group_id': {'required': True}, + 'error_code': {'required': True}, + 'error_status': {'required': True}, + } + + _attribute_map = { + 'enrollment_group_id': {'key': 'enrollmentGroupId', 'type': 'str'}, + 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'error_status': {'key': 'errorStatus', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(BulkEnrollmentGroupOperationError, self).__init__(**kwargs) + self.enrollment_group_id = kwargs.get('enrollment_group_id', None) + self.error_code = kwargs.get('error_code', None) + self.error_status = kwargs.get('error_status', None) diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_error_py3.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_error_py3.py new file mode 100644 index 000000000..09904f613 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_error_py3.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentGroupOperationError(Model): + """Bulk enrollment operation error. + + All required parameters must be populated in order to send to Azure. + + :param enrollment_group_id: Required. Enrollment group id. + :type enrollment_group_id: str + :param error_code: Required. Error code + :type error_code: int + :param error_status: Required. Error status. + :type error_status: str + """ + + _validation = { + 'enrollment_group_id': {'required': True}, + 'error_code': {'required': True}, + 'error_status': {'required': True}, + } + + _attribute_map = { + 'enrollment_group_id': {'key': 'enrollmentGroupId', 'type': 'str'}, + 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'error_status': {'key': 'errorStatus', 'type': 'str'}, + } + + def __init__(self, *, enrollment_group_id: str, error_code: int, error_status: str, **kwargs) -> None: + super(BulkEnrollmentGroupOperationError, self).__init__(**kwargs) + self.enrollment_group_id = enrollment_group_id + self.error_code = error_code + self.error_status = error_status diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_py3.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_py3.py new file mode 100644 index 000000000..0fd1c67a1 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentGroupOperation(Model): + """Bulk enrollment operation. + + All required parameters must be populated in order to send to Azure. + + :param enrollment_groups: Required. Enrollment items + :type enrollment_groups: list[~dps.models.EnrollmentGroup] + :param mode: Required. Operation mode. Possible values include: 'create', + 'update', 'updateIfMatchETag', 'delete' + :type mode: str or ~dps.models.enum + """ + + _validation = { + 'enrollment_groups': {'required': True}, + 'mode': {'required': True}, + } + + _attribute_map = { + 'enrollment_groups': {'key': 'enrollmentGroups', 'type': '[EnrollmentGroup]'}, + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__(self, *, enrollment_groups, mode, **kwargs) -> None: + super(BulkEnrollmentGroupOperation, self).__init__(**kwargs) + self.enrollment_groups = enrollment_groups + self.mode = mode diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_result.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_result.py new file mode 100644 index 000000000..cd110069b --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_result.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentGroupOperationResult(Model): + """Results of a bulk enrollment group operation. + + All required parameters must be populated in order to send to Azure. + + :param errors: Registration errors + :type errors: list[~dps.models.BulkEnrollmentGroupOperationError] + :param is_successful: Required. Indicates if the operation was successful + in its entirety. + :type is_successful: bool + """ + + _validation = { + 'is_successful': {'required': True}, + } + + _attribute_map = { + 'errors': {'key': 'errors', 'type': '[BulkEnrollmentGroupOperationError]'}, + 'is_successful': {'key': 'isSuccessful', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(BulkEnrollmentGroupOperationResult, self).__init__(**kwargs) + self.errors = kwargs.get('errors', None) + self.is_successful = kwargs.get('is_successful', None) diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_result_py3.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_result_py3.py new file mode 100644 index 000000000..d4818887f --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_group_operation_result_py3.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentGroupOperationResult(Model): + """Results of a bulk enrollment group operation. + + All required parameters must be populated in order to send to Azure. + + :param errors: Registration errors + :type errors: list[~dps.models.BulkEnrollmentGroupOperationError] + :param is_successful: Required. Indicates if the operation was successful + in its entirety. + :type is_successful: bool + """ + + _validation = { + 'is_successful': {'required': True}, + } + + _attribute_map = { + 'errors': {'key': 'errors', 'type': '[BulkEnrollmentGroupOperationError]'}, + 'is_successful': {'key': 'isSuccessful', 'type': 'bool'}, + } + + def __init__(self, *, is_successful: bool, errors=None, **kwargs) -> None: + super(BulkEnrollmentGroupOperationResult, self).__init__(**kwargs) + self.errors = errors + self.is_successful = is_successful diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_operation.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation.py new file mode 100644 index 000000000..096c0f78b --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentOperation(Model): + """Bulk enrollment operation. + + All required parameters must be populated in order to send to Azure. + + :param enrollments: Required. Enrollment items + :type enrollments: list[~dps.models.IndividualEnrollment] + :param mode: Required. Operation mode. Possible values include: 'create', + 'update', 'updateIfMatchETag', 'delete' + :type mode: str or ~dps.models.enum + """ + + _validation = { + 'enrollments': {'required': True}, + 'mode': {'required': True}, + } + + _attribute_map = { + 'enrollments': {'key': 'enrollments', 'type': '[IndividualEnrollment]'}, + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(BulkEnrollmentOperation, self).__init__(**kwargs) + self.enrollments = kwargs.get('enrollments', None) + self.mode = kwargs.get('mode', None) diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_error.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_error.py new file mode 100644 index 000000000..73c137939 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_error.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentOperationError(Model): + """Bulk enrollment operation error. + + All required parameters must be populated in order to send to Azure. + + :param registration_id: Required. Device registration id. + :type registration_id: str + :param error_code: Required. Error code + :type error_code: int + :param error_status: Required. Error status. + :type error_status: str + """ + + _validation = { + 'registration_id': {'required': True}, + 'error_code': {'required': True}, + 'error_status': {'required': True}, + } + + _attribute_map = { + 'registration_id': {'key': 'registrationId', 'type': 'str'}, + 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'error_status': {'key': 'errorStatus', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(BulkEnrollmentOperationError, self).__init__(**kwargs) + self.registration_id = kwargs.get('registration_id', None) + self.error_code = kwargs.get('error_code', None) + self.error_status = kwargs.get('error_status', None) diff --git a/azext_iot/sdk/dps/models/bulk_enrollment_operation_error.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_error_py3.py similarity index 65% rename from azext_iot/sdk/dps/models/bulk_enrollment_operation_error.py rename to azext_iot/sdk/dps/service/models/bulk_enrollment_operation_error_py3.py index c995e899c..a8f798ba5 100644 --- a/azext_iot/sdk/dps/models/bulk_enrollment_operation_error.py +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_error_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,11 +15,13 @@ class BulkEnrollmentOperationError(Model): """Bulk enrollment operation error. - :param registration_id: Device registration id. + All required parameters must be populated in order to send to Azure. + + :param registration_id: Required. Device registration id. :type registration_id: str - :param error_code: Error code + :param error_code: Required. Error code :type error_code: int - :param error_status: Error status + :param error_status: Required. Error status. :type error_status: str """ @@ -31,8 +37,8 @@ class BulkEnrollmentOperationError(Model): 'error_status': {'key': 'errorStatus', 'type': 'str'}, } - def __init__(self, registration_id, error_code, error_status): - super(BulkEnrollmentOperationError, self).__init__() + def __init__(self, *, registration_id: str, error_code: int, error_status: str, **kwargs) -> None: + super(BulkEnrollmentOperationError, self).__init__(**kwargs) self.registration_id = registration_id self.error_code = error_code self.error_status = error_status diff --git a/azext_iot/sdk/dps/models/bulk_enrollment_operation.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_py3.py similarity index 52% rename from azext_iot/sdk/dps/models/bulk_enrollment_operation.py rename to azext_iot/sdk/dps/service/models/bulk_enrollment_operation_py3.py index 4a86015e9..7f2c61530 100644 --- a/azext_iot/sdk/dps/models/bulk_enrollment_operation.py +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -9,15 +13,15 @@ class BulkEnrollmentOperation(Model): - """Bulk operation. - - :param enrollments: Enrollment items - :type enrollments: - list[~microsoft.azure.management.provisioningservices.models.IndividualEnrollment] - :param mode: Operation mode. Possible values include: 'create', 'update', - 'updateIfMatchETag', 'delete' - :type mode: str or - ~microsoft.azure.management.provisioningservices.models.enum + """Bulk enrollment operation. + + All required parameters must be populated in order to send to Azure. + + :param enrollments: Required. Enrollment items + :type enrollments: list[~dps.models.IndividualEnrollment] + :param mode: Required. Operation mode. Possible values include: 'create', + 'update', 'updateIfMatchETag', 'delete' + :type mode: str or ~dps.models.enum """ _validation = { @@ -30,7 +34,7 @@ class BulkEnrollmentOperation(Model): 'mode': {'key': 'mode', 'type': 'str'}, } - def __init__(self, enrollments, mode): - super(BulkEnrollmentOperation, self).__init__() + def __init__(self, *, enrollments, mode, **kwargs) -> None: + super(BulkEnrollmentOperation, self).__init__(**kwargs) self.enrollments = enrollments self.mode = mode diff --git a/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_result.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_result.py new file mode 100644 index 000000000..47df002ac --- /dev/null +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_result.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class BulkEnrollmentOperationResult(Model): + """Results of a bulk enrollment operation. + + All required parameters must be populated in order to send to Azure. + + :param errors: Registration errors + :type errors: list[~dps.models.BulkEnrollmentOperationError] + :param is_successful: Required. Indicates if the operation was successful + in its entirety. + :type is_successful: bool + """ + + _validation = { + 'is_successful': {'required': True}, + } + + _attribute_map = { + 'errors': {'key': 'errors', 'type': '[BulkEnrollmentOperationError]'}, + 'is_successful': {'key': 'isSuccessful', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(BulkEnrollmentOperationResult, self).__init__(**kwargs) + self.errors = kwargs.get('errors', None) + self.is_successful = kwargs.get('is_successful', None) diff --git a/azext_iot/sdk/dps/models/bulk_enrollment_operation_result.py b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_result_py3.py similarity index 57% rename from azext_iot/sdk/dps/models/bulk_enrollment_operation_result.py rename to azext_iot/sdk/dps/service/models/bulk_enrollment_operation_result_py3.py index c9f8ab121..cfaccb020 100644 --- a/azext_iot/sdk/dps/models/bulk_enrollment_operation_result.py +++ b/azext_iot/sdk/dps/service/models/bulk_enrollment_operation_result_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -9,14 +13,15 @@ class BulkEnrollmentOperationResult(Model): - """BulkEnrollmentOperationResult. + """Results of a bulk enrollment operation. + + All required parameters must be populated in order to send to Azure. - :param is_successful: Indicates if the operation was successful in its - entirety - :type is_successful: bool :param errors: Registration errors - :type errors: - list[~microsoft.azure.management.provisioningservices.models.BulkEnrollmentOperationError] + :type errors: list[~dps.models.BulkEnrollmentOperationError] + :param is_successful: Required. Indicates if the operation was successful + in its entirety. + :type is_successful: bool """ _validation = { @@ -24,11 +29,11 @@ class BulkEnrollmentOperationResult(Model): } _attribute_map = { - 'is_successful': {'key': 'isSuccessful', 'type': 'bool'}, 'errors': {'key': 'errors', 'type': '[BulkEnrollmentOperationError]'}, + 'is_successful': {'key': 'isSuccessful', 'type': 'bool'}, } - def __init__(self, is_successful, errors=None): - super(BulkEnrollmentOperationResult, self).__init__() - self.is_successful = is_successful + def __init__(self, *, is_successful: bool, errors=None, **kwargs) -> None: + super(BulkEnrollmentOperationResult, self).__init__(**kwargs) self.errors = errors + self.is_successful = is_successful diff --git a/azext_iot/sdk/dps/service/models/custom_allocation_definition.py b/azext_iot/sdk/dps/service/models/custom_allocation_definition.py new file mode 100644 index 000000000..b53f86fe8 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/custom_allocation_definition.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CustomAllocationDefinition(Model): + """Custom allocation definition. + + All required parameters must be populated in order to send to Azure. + + :param webhook_url: Required. The webhook URL used for allocation + requests. + :type webhook_url: str + :param api_version: Required. The API version of the provisioning service + types (such as IndividualEnrollment) sent in the custom allocation + request. Minimum supported version: "2018-09-01-preview". + :type api_version: str + """ + + _validation = { + 'webhook_url': {'required': True}, + 'api_version': {'required': True}, + } + + _attribute_map = { + 'webhook_url': {'key': 'webhookUrl', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CustomAllocationDefinition, self).__init__(**kwargs) + self.webhook_url = kwargs.get('webhook_url', None) + self.api_version = kwargs.get('api_version', None) diff --git a/azext_iot/sdk/dps/models/custom_allocation_definition.py b/azext_iot/sdk/dps/service/models/custom_allocation_definition_py3.py similarity index 55% rename from azext_iot/sdk/dps/models/custom_allocation_definition.py rename to azext_iot/sdk/dps/service/models/custom_allocation_definition_py3.py index 32c7e7a02..4174a9d4a 100644 --- a/azext_iot/sdk/dps/models/custom_allocation_definition.py +++ b/azext_iot/sdk/dps/service/models/custom_allocation_definition_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,11 +15,14 @@ class CustomAllocationDefinition(Model): """Custom allocation definition. - :param webhook_url: The webhook URL used for allocation requests. + All required parameters must be populated in order to send to Azure. + + :param webhook_url: Required. The webhook URL used for allocation + requests. :type webhook_url: str - :param api_version: The API version of the provisioning service types - (such as IndividualEnrollment) sent in the custom allocation request. - Supported versions include: "2018-09-01-preview" + :param api_version: Required. The API version of the provisioning service + types (such as IndividualEnrollment) sent in the custom allocation + request. Minimum supported version: "2018-09-01-preview". :type api_version: str """ @@ -29,7 +36,7 @@ class CustomAllocationDefinition(Model): 'api_version': {'key': 'apiVersion', 'type': 'str'}, } - def __init__(self, webhook_url, api_version): - super(CustomAllocationDefinition, self).__init__() + def __init__(self, *, webhook_url: str, api_version: str, **kwargs) -> None: + super(CustomAllocationDefinition, self).__init__(**kwargs) self.webhook_url = webhook_url self.api_version = api_version diff --git a/azext_iot/sdk/dps/service/models/device_capabilities.py b/azext_iot/sdk/dps/service/models/device_capabilities.py new file mode 100644 index 000000000..271a48292 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/device_capabilities.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DeviceCapabilities(Model): + """Device capabilities. + + All required parameters must be populated in order to send to Azure. + + :param iot_edge: Required. If set to true, this device is an IoTEdge + device. Default value: False . + :type iot_edge: bool + """ + + _validation = { + 'iot_edge': {'required': True}, + } + + _attribute_map = { + 'iot_edge': {'key': 'iotEdge', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(DeviceCapabilities, self).__init__(**kwargs) + self.iot_edge = kwargs.get('iot_edge', False) diff --git a/azext_iot/sdk/dps/models/device_capabilities.py b/azext_iot/sdk/dps/service/models/device_capabilities_py3.py similarity index 57% rename from azext_iot/sdk/dps/models/device_capabilities.py rename to azext_iot/sdk/dps/service/models/device_capabilities_py3.py index 5aeed1c3c..55539a142 100644 --- a/azext_iot/sdk/dps/models/device_capabilities.py +++ b/azext_iot/sdk/dps/service/models/device_capabilities_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,8 +15,10 @@ class DeviceCapabilities(Model): """Device capabilities. - :param iot_edge: If set to true, this device is an IoTEdge device. Default - value: False . + All required parameters must be populated in order to send to Azure. + + :param iot_edge: Required. If set to true, this device is an IoTEdge + device. Default value: False . :type iot_edge: bool """ @@ -24,6 +30,6 @@ class DeviceCapabilities(Model): 'iot_edge': {'key': 'iotEdge', 'type': 'bool'}, } - def __init__(self, iot_edge=False): - super(DeviceCapabilities, self).__init__() + def __init__(self, *, iot_edge: bool=False, **kwargs) -> None: + super(DeviceCapabilities, self).__init__(**kwargs) self.iot_edge = iot_edge diff --git a/azext_iot/sdk/dps/models/device_registration_state.py b/azext_iot/sdk/dps/service/models/device_registration_state.py similarity index 85% rename from azext_iot/sdk/dps/models/device_registration_state.py rename to azext_iot/sdk/dps/service/models/device_registration_state.py index 235205aa5..9d34f7853 100644 --- a/azext_iot/sdk/dps/models/device_registration_state.py +++ b/azext_iot/sdk/dps/service/models/device_registration_state.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -25,8 +29,7 @@ class DeviceRegistrationState(Model): :vartype device_id: str :ivar status: Enrollment status. Possible values include: 'unassigned', 'assigning', 'assigned', 'failed', 'disabled' - :vartype status: str or - ~microsoft.azure.management.provisioningservices.models.enum + :vartype status: str or ~dps.models.enum :ivar substatus: Substatus for 'Assigned' devices. Possible values include - 'initialAssignment': Device has been assigned to an IoT hub for the first time, 'deviceDataMigrated': Device has been assigned to a different @@ -37,8 +40,7 @@ class DeviceRegistrationState(Model): enrollment. Device data was removed from the previously assigned IoT hub. Possible values include: 'initialAssignment', 'deviceDataMigrated', 'deviceDataReset' - :vartype substatus: str or - ~microsoft.azure.management.provisioningservices.models.enum + :vartype substatus: str or ~dps.models.enum :ivar error_code: Error code. :vartype error_code: int :ivar error_message: Error message. @@ -47,6 +49,9 @@ class DeviceRegistrationState(Model): :vartype last_updated_date_time_utc: datetime :ivar etag: The entity tag associated with the resource. :vartype etag: str + :ivar payload: Custom allocation payload returned from the webhook to the + device. + :vartype payload: object """ _validation = { @@ -60,6 +65,7 @@ class DeviceRegistrationState(Model): 'error_message': {'readonly': True}, 'last_updated_date_time_utc': {'readonly': True}, 'etag': {'readonly': True}, + 'payload': {'readonly': True}, } _attribute_map = { @@ -73,10 +79,11 @@ class DeviceRegistrationState(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, 'last_updated_date_time_utc': {'key': 'lastUpdatedDateTimeUtc', 'type': 'iso-8601'}, 'etag': {'key': 'etag', 'type': 'str'}, + 'payload': {'key': 'payload', 'type': 'object'}, } - def __init__(self): - super(DeviceRegistrationState, self).__init__() + def __init__(self, **kwargs): + super(DeviceRegistrationState, self).__init__(**kwargs) self.registration_id = None self.created_date_time_utc = None self.assigned_hub = None @@ -87,3 +94,4 @@ def __init__(self): self.error_message = None self.last_updated_date_time_utc = None self.etag = None + self.payload = None diff --git a/azext_iot/sdk/dps/models/individual_enrollment_registration_state.py b/azext_iot/sdk/dps/service/models/device_registration_state_py3.py similarity index 58% rename from azext_iot/sdk/dps/models/individual_enrollment_registration_state.py rename to azext_iot/sdk/dps/service/models/device_registration_state_py3.py index 46c77709a..dd61aab73 100644 --- a/azext_iot/sdk/dps/models/individual_enrollment_registration_state.py +++ b/azext_iot/sdk/dps/service/models/device_registration_state_py3.py @@ -1,15 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from .device_registration_state import DeviceRegistrationState +from msrest.serialization import Model -class IndividualEnrollmentRegistrationState(DeviceRegistrationState): - """Current registration status. +class DeviceRegistrationState(Model): + """Device registration state. Variables are only populated by the server, and will be ignored when sending a request. @@ -25,8 +29,7 @@ class IndividualEnrollmentRegistrationState(DeviceRegistrationState): :vartype device_id: str :ivar status: Enrollment status. Possible values include: 'unassigned', 'assigning', 'assigned', 'failed', 'disabled' - :vartype status: str or - ~microsoft.azure.management.provisioningservices.models.enum + :vartype status: str or ~dps.models.enum :ivar substatus: Substatus for 'Assigned' devices. Possible values include - 'initialAssignment': Device has been assigned to an IoT hub for the first time, 'deviceDataMigrated': Device has been assigned to a different @@ -37,8 +40,7 @@ class IndividualEnrollmentRegistrationState(DeviceRegistrationState): enrollment. Device data was removed from the previously assigned IoT hub. Possible values include: 'initialAssignment', 'deviceDataMigrated', 'deviceDataReset' - :vartype substatus: str or - ~microsoft.azure.management.provisioningservices.models.enum + :vartype substatus: str or ~dps.models.enum :ivar error_code: Error code. :vartype error_code: int :ivar error_message: Error message. @@ -47,6 +49,9 @@ class IndividualEnrollmentRegistrationState(DeviceRegistrationState): :vartype last_updated_date_time_utc: datetime :ivar etag: The entity tag associated with the resource. :vartype etag: str + :ivar payload: Custom allocation payload returned from the webhook to the + device. + :vartype payload: object """ _validation = { @@ -60,7 +65,33 @@ class IndividualEnrollmentRegistrationState(DeviceRegistrationState): 'error_message': {'readonly': True}, 'last_updated_date_time_utc': {'readonly': True}, 'etag': {'readonly': True}, + 'payload': {'readonly': True}, } - def __init__(self): - super(IndividualEnrollmentRegistrationState, self).__init__() + _attribute_map = { + 'registration_id': {'key': 'registrationId', 'type': 'str'}, + 'created_date_time_utc': {'key': 'createdDateTimeUtc', 'type': 'iso-8601'}, + 'assigned_hub': {'key': 'assignedHub', 'type': 'str'}, + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'substatus': {'key': 'substatus', 'type': 'str'}, + 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, + 'last_updated_date_time_utc': {'key': 'lastUpdatedDateTimeUtc', 'type': 'iso-8601'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'payload': {'key': 'payload', 'type': 'object'}, + } + + def __init__(self, **kwargs) -> None: + super(DeviceRegistrationState, self).__init__(**kwargs) + self.registration_id = None + self.created_date_time_utc = None + self.assigned_hub = None + self.device_id = None + self.status = None + self.substatus = None + self.error_code = None + self.error_message = None + self.last_updated_date_time_utc = None + self.etag = None + self.payload = None diff --git a/azext_iot/sdk/dps/service/models/enrollment_group.py b/azext_iot/sdk/dps/service/models/enrollment_group.py new file mode 100644 index 000000000..1b19345a4 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/enrollment_group.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class EnrollmentGroup(Model): + """Enrollment group record. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param enrollment_group_id: Required. Enrollment Group ID. + :type enrollment_group_id: str + :param attestation: Required. Attestation method used by the device. + :type attestation: ~dps.models.AttestationMechanism + :param capabilities: Capabilities of the device. + :type capabilities: ~dps.models.DeviceCapabilities + :param iot_hub_host_name: The Iot Hub host name. + :type iot_hub_host_name: str + :param initial_twin: Initial device twin. + :type initial_twin: ~dps.models.InitialTwin + :param etag: The entity tag associated with the resource. + :type etag: str + :param provisioning_status: The provisioning status. Possible values + include: 'enabled', 'disabled'. Default value: "enabled" . + :type provisioning_status: str or ~dps.models.enum + :param reprovision_policy: The behavior when a device is re-provisioned to + an IoT hub. + :type reprovision_policy: ~dps.models.ReprovisionPolicy + :ivar created_date_time_utc: The DateTime this resource was created. + :vartype created_date_time_utc: datetime + :ivar last_updated_date_time_utc: The DateTime this resource was last + updated. + :vartype last_updated_date_time_utc: datetime + :param allocation_policy: The allocation policy of this resource. This + policy overrides the tenant level allocation policy for this individual + enrollment or enrollment group. Possible values include 'hashed': Linked + IoT hubs are equally likely to have devices provisioned to them, + 'geoLatency': Devices are provisioned to an IoT hub with the lowest + latency to the device.If multiple linked IoT hubs would provide the same + lowest latency, the provisioning service hashes devices across those hubs, + 'static' : Specification of the desired IoT hub in the enrollment list + takes priority over the service-level allocation policy, 'custom': Devices + are provisioned to an IoT hub based on your own custom logic. The + provisioning service passes information about the device to the logic, and + the logic returns the desired IoT hub as well as the desired initial + configuration. We recommend using Azure Functions to host your logic. + Possible values include: 'hashed', 'geoLatency', 'static', 'custom' + :type allocation_policy: str or ~dps.models.enum + :param iot_hubs: The list of names of IoT hubs the device(s) in this + resource can be allocated to. Must be a subset of tenant level list of IoT + hubs. + :type iot_hubs: list[str] + :param custom_allocation_definition: Custom allocation definition. + :type custom_allocation_definition: ~dps.models.CustomAllocationDefinition + """ + + _validation = { + 'enrollment_group_id': {'required': True}, + 'attestation': {'required': True}, + 'created_date_time_utc': {'readonly': True}, + 'last_updated_date_time_utc': {'readonly': True}, + } + + _attribute_map = { + 'enrollment_group_id': {'key': 'enrollmentGroupId', 'type': 'str'}, + 'attestation': {'key': 'attestation', 'type': 'AttestationMechanism'}, + 'capabilities': {'key': 'capabilities', 'type': 'DeviceCapabilities'}, + 'iot_hub_host_name': {'key': 'iotHubHostName', 'type': 'str'}, + 'initial_twin': {'key': 'initialTwin', 'type': 'InitialTwin'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, + 'reprovision_policy': {'key': 'reprovisionPolicy', 'type': 'ReprovisionPolicy'}, + 'created_date_time_utc': {'key': 'createdDateTimeUtc', 'type': 'iso-8601'}, + 'last_updated_date_time_utc': {'key': 'lastUpdatedDateTimeUtc', 'type': 'iso-8601'}, + 'allocation_policy': {'key': 'allocationPolicy', 'type': 'str'}, + 'iot_hubs': {'key': 'iotHubs', 'type': '[str]'}, + 'custom_allocation_definition': {'key': 'customAllocationDefinition', 'type': 'CustomAllocationDefinition'}, + } + + def __init__(self, **kwargs): + super(EnrollmentGroup, self).__init__(**kwargs) + self.enrollment_group_id = kwargs.get('enrollment_group_id', None) + self.attestation = kwargs.get('attestation', None) + self.capabilities = kwargs.get('capabilities', None) + self.iot_hub_host_name = kwargs.get('iot_hub_host_name', None) + self.initial_twin = kwargs.get('initial_twin', None) + self.etag = kwargs.get('etag', None) + self.provisioning_status = kwargs.get('provisioning_status', "enabled") + self.reprovision_policy = kwargs.get('reprovision_policy', None) + self.created_date_time_utc = None + self.last_updated_date_time_utc = None + self.allocation_policy = kwargs.get('allocation_policy', None) + self.iot_hubs = kwargs.get('iot_hubs', None) + self.custom_allocation_definition = kwargs.get('custom_allocation_definition', None) diff --git a/azext_iot/sdk/dps/models/enrollment_group.py b/azext_iot/sdk/dps/service/models/enrollment_group_py3.py similarity index 76% rename from azext_iot/sdk/dps/models/enrollment_group.py rename to azext_iot/sdk/dps/service/models/enrollment_group_py3.py index 5acc55954..11dbb59bf 100644 --- a/azext_iot/sdk/dps/models/enrollment_group.py +++ b/azext_iot/sdk/dps/service/models/enrollment_group_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -14,29 +18,26 @@ class EnrollmentGroup(Model): Variables are only populated by the server, and will be ignored when sending a request. - :param enrollment_group_id: Enrollment Group ID. + All required parameters must be populated in order to send to Azure. + + :param enrollment_group_id: Required. Enrollment Group ID. :type enrollment_group_id: str - :param attestation: Attestation method used by the device. - :type attestation: - ~microsoft.azure.management.provisioningservices.models.AttestationMechanism - :param capabilities: Capabilities of the device - :type capabilities: - ~microsoft.azure.management.provisioningservices.models.DeviceCapabilities + :param attestation: Required. Attestation method used by the device. + :type attestation: ~dps.models.AttestationMechanism + :param capabilities: Capabilities of the device. + :type capabilities: ~dps.models.DeviceCapabilities :param iot_hub_host_name: The Iot Hub host name. :type iot_hub_host_name: str :param initial_twin: Initial device twin. - :type initial_twin: - ~microsoft.azure.management.provisioningservices.models.InitialTwin + :type initial_twin: ~dps.models.InitialTwin :param etag: The entity tag associated with the resource. :type etag: str :param provisioning_status: The provisioning status. Possible values include: 'enabled', 'disabled'. Default value: "enabled" . - :type provisioning_status: str or - ~microsoft.azure.management.provisioningservices.models.enum + :type provisioning_status: str or ~dps.models.enum :param reprovision_policy: The behavior when a device is re-provisioned to an IoT hub. - :type reprovision_policy: - ~microsoft.azure.management.provisioningservices.models.ReprovisionPolicy + :type reprovision_policy: ~dps.models.ReprovisionPolicy :ivar created_date_time_utc: The DateTime this resource was created. :vartype created_date_time_utc: datetime :ivar last_updated_date_time_utc: The DateTime this resource was last @@ -56,15 +57,13 @@ class EnrollmentGroup(Model): the logic returns the desired IoT hub as well as the desired initial configuration. We recommend using Azure Functions to host your logic. Possible values include: 'hashed', 'geoLatency', 'static', 'custom' - :type allocation_policy: str or - ~microsoft.azure.management.provisioningservices.models.enum + :type allocation_policy: str or ~dps.models.enum :param iot_hubs: The list of names of IoT hubs the device(s) in this resource can be allocated to. Must be a subset of tenant level list of IoT hubs. :type iot_hubs: list[str] :param custom_allocation_definition: Custom allocation definition. - :type custom_allocation_definition: - ~microsoft.azure.management.provisioningservices.models.CustomAllocationDefinition + :type custom_allocation_definition: ~dps.models.CustomAllocationDefinition """ _validation = { @@ -75,9 +74,9 @@ class EnrollmentGroup(Model): } _attribute_map = { - 'capabilities': {'key': 'capabilities', 'type': 'DeviceCapabilities'}, # @digimaun - added capabilities custom 'enrollment_group_id': {'key': 'enrollmentGroupId', 'type': 'str'}, 'attestation': {'key': 'attestation', 'type': 'AttestationMechanism'}, + 'capabilities': {'key': 'capabilities', 'type': 'DeviceCapabilities'}, 'iot_hub_host_name': {'key': 'iotHubHostName', 'type': 'str'}, 'initial_twin': {'key': 'initialTwin', 'type': 'InitialTwin'}, 'etag': {'key': 'etag', 'type': 'str'}, @@ -90,11 +89,11 @@ class EnrollmentGroup(Model): 'custom_allocation_definition': {'key': 'customAllocationDefinition', 'type': 'CustomAllocationDefinition'}, } - def __init__(self, enrollment_group_id, attestation, capabilities=None, iot_hub_host_name=None, initial_twin=None, etag=None, provisioning_status="enabled", reprovision_policy=None, allocation_policy=None, iot_hubs=None, custom_allocation_definition=None): - super(EnrollmentGroup, self).__init__() - self.capabilities = capabilities # @digmaun - added capabilities custom + def __init__(self, *, enrollment_group_id: str, attestation, capabilities=None, iot_hub_host_name: str=None, initial_twin=None, etag: str=None, provisioning_status="enabled", reprovision_policy=None, allocation_policy=None, iot_hubs=None, custom_allocation_definition=None, **kwargs) -> None: + super(EnrollmentGroup, self).__init__(**kwargs) self.enrollment_group_id = enrollment_group_id self.attestation = attestation + self.capabilities = capabilities self.iot_hub_host_name = iot_hub_host_name self.initial_twin = initial_twin self.etag = etag diff --git a/azext_iot/sdk/dps/service/models/individual_enrollment.py b/azext_iot/sdk/dps/service/models/individual_enrollment.py new file mode 100644 index 000000000..5fe9a325a --- /dev/null +++ b/azext_iot/sdk/dps/service/models/individual_enrollment.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IndividualEnrollment(Model): + """The device enrollment record. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param registration_id: Required. The registration ID is alphanumeric, + lowercase, and may contain hyphens. + :type registration_id: str + :param device_id: Desired IoT Hub device ID (optional). + :type device_id: str + :ivar registration_state: Current registration status. + :vartype registration_state: ~dps.models.DeviceRegistrationState + :param attestation: Required. Attestation method used by the device. + :type attestation: ~dps.models.AttestationMechanism + :param capabilities: Capabilities of the device. + :type capabilities: ~dps.models.DeviceCapabilities + :param iot_hub_host_name: The Iot Hub host name. + :type iot_hub_host_name: str + :param initial_twin: Initial device twin. + :type initial_twin: ~dps.models.InitialTwin + :param etag: The entity tag associated with the resource. + :type etag: str + :param provisioning_status: The provisioning status. Possible values + include: 'enabled', 'disabled'. Default value: "enabled" . + :type provisioning_status: str or ~dps.models.enum + :param reprovision_policy: The behavior when a device is re-provisioned to + an IoT hub. + :type reprovision_policy: ~dps.models.ReprovisionPolicy + :ivar created_date_time_utc: The DateTime this resource was created. + :vartype created_date_time_utc: datetime + :ivar last_updated_date_time_utc: The DateTime this resource was last + updated. + :vartype last_updated_date_time_utc: datetime + :param allocation_policy: The allocation policy of this resource. This + policy overrides the tenant level allocation policy for this individual + enrollment or enrollment group. Possible values include 'hashed': Linked + IoT hubs are equally likely to have devices provisioned to them, + 'geoLatency': Devices are provisioned to an IoT hub with the lowest + latency to the device.If multiple linked IoT hubs would provide the same + lowest latency, the provisioning service hashes devices across those hubs, + 'static' : Specification of the desired IoT hub in the enrollment list + takes priority over the service-level allocation policy, 'custom': Devices + are provisioned to an IoT hub based on your own custom logic. The + provisioning service passes information about the device to the logic, and + the logic returns the desired IoT hub as well as the desired initial + configuration. We recommend using Azure Functions to host your logic. + Possible values include: 'hashed', 'geoLatency', 'static', 'custom' + :type allocation_policy: str or ~dps.models.enum + :param iot_hubs: The list of names of IoT hubs the device(s) in this + resource can be allocated to. Must be a subset of tenant level list of IoT + hubs. + :type iot_hubs: list[str] + :param custom_allocation_definition: Custom allocation definition. + :type custom_allocation_definition: ~dps.models.CustomAllocationDefinition + """ + + _validation = { + 'registration_id': {'required': True}, + 'registration_state': {'readonly': True}, + 'attestation': {'required': True}, + 'created_date_time_utc': {'readonly': True}, + 'last_updated_date_time_utc': {'readonly': True}, + } + + _attribute_map = { + 'registration_id': {'key': 'registrationId', 'type': 'str'}, + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'registration_state': {'key': 'registrationState', 'type': 'DeviceRegistrationState'}, + 'attestation': {'key': 'attestation', 'type': 'AttestationMechanism'}, + 'capabilities': {'key': 'capabilities', 'type': 'DeviceCapabilities'}, + 'iot_hub_host_name': {'key': 'iotHubHostName', 'type': 'str'}, + 'initial_twin': {'key': 'initialTwin', 'type': 'InitialTwin'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, + 'reprovision_policy': {'key': 'reprovisionPolicy', 'type': 'ReprovisionPolicy'}, + 'created_date_time_utc': {'key': 'createdDateTimeUtc', 'type': 'iso-8601'}, + 'last_updated_date_time_utc': {'key': 'lastUpdatedDateTimeUtc', 'type': 'iso-8601'}, + 'allocation_policy': {'key': 'allocationPolicy', 'type': 'str'}, + 'iot_hubs': {'key': 'iotHubs', 'type': '[str]'}, + 'custom_allocation_definition': {'key': 'customAllocationDefinition', 'type': 'CustomAllocationDefinition'}, + } + + def __init__(self, **kwargs): + super(IndividualEnrollment, self).__init__(**kwargs) + self.registration_id = kwargs.get('registration_id', None) + self.device_id = kwargs.get('device_id', None) + self.registration_state = None + self.attestation = kwargs.get('attestation', None) + self.capabilities = kwargs.get('capabilities', None) + self.iot_hub_host_name = kwargs.get('iot_hub_host_name', None) + self.initial_twin = kwargs.get('initial_twin', None) + self.etag = kwargs.get('etag', None) + self.provisioning_status = kwargs.get('provisioning_status', "enabled") + self.reprovision_policy = kwargs.get('reprovision_policy', None) + self.created_date_time_utc = None + self.last_updated_date_time_utc = None + self.allocation_policy = kwargs.get('allocation_policy', None) + self.iot_hubs = kwargs.get('iot_hubs', None) + self.custom_allocation_definition = kwargs.get('custom_allocation_definition', None) diff --git a/azext_iot/sdk/dps/models/individual_enrollment.py b/azext_iot/sdk/dps/service/models/individual_enrollment_py3.py similarity index 76% rename from azext_iot/sdk/dps/models/individual_enrollment.py rename to azext_iot/sdk/dps/service/models/individual_enrollment_py3.py index bf4f4e6e2..aca250416 100644 --- a/azext_iot/sdk/dps/models/individual_enrollment.py +++ b/azext_iot/sdk/dps/service/models/individual_enrollment_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -14,35 +18,31 @@ class IndividualEnrollment(Model): Variables are only populated by the server, and will be ignored when sending a request. - :param capabilities: Capabilities of the device - :type capabilities: - ~microsoft.azure.management.provisioningservices.models.DeviceCapabilities - :param registration_id: The registration ID is alphanumeric, lowercase, - and may contain hyphens. + All required parameters must be populated in order to send to Azure. + + :param registration_id: Required. The registration ID is alphanumeric, + lowercase, and may contain hyphens. :type registration_id: str :param device_id: Desired IoT Hub device ID (optional). :type device_id: str :ivar registration_state: Current registration status. - :vartype registration_state: - ~microsoft.azure.management.provisioningservices.models.IndividualEnrollmentRegistrationState - :param attestation: Attestation method used by the device. - :type attestation: - ~microsoft.azure.management.provisioningservices.models.AttestationMechanism + :vartype registration_state: ~dps.models.DeviceRegistrationState + :param attestation: Required. Attestation method used by the device. + :type attestation: ~dps.models.AttestationMechanism + :param capabilities: Capabilities of the device. + :type capabilities: ~dps.models.DeviceCapabilities :param iot_hub_host_name: The Iot Hub host name. :type iot_hub_host_name: str :param initial_twin: Initial device twin. - :type initial_twin: - ~microsoft.azure.management.provisioningservices.models.InitialTwin + :type initial_twin: ~dps.models.InitialTwin :param etag: The entity tag associated with the resource. :type etag: str :param provisioning_status: The provisioning status. Possible values include: 'enabled', 'disabled'. Default value: "enabled" . - :type provisioning_status: str or - ~microsoft.azure.management.provisioningservices.models.enum + :type provisioning_status: str or ~dps.models.enum :param reprovision_policy: The behavior when a device is re-provisioned to an IoT hub. - :type reprovision_policy: - ~microsoft.azure.management.provisioningservices.models.ReprovisionPolicy + :type reprovision_policy: ~dps.models.ReprovisionPolicy :ivar created_date_time_utc: The DateTime this resource was created. :vartype created_date_time_utc: datetime :ivar last_updated_date_time_utc: The DateTime this resource was last @@ -62,15 +62,13 @@ class IndividualEnrollment(Model): the logic returns the desired IoT hub as well as the desired initial configuration. We recommend using Azure Functions to host your logic. Possible values include: 'hashed', 'geoLatency', 'static', 'custom' - :type allocation_policy: str or - ~microsoft.azure.management.provisioningservices.models.enum + :type allocation_policy: str or ~dps.models.enum :param iot_hubs: The list of names of IoT hubs the device(s) in this resource can be allocated to. Must be a subset of tenant level list of IoT hubs. :type iot_hubs: list[str] :param custom_allocation_definition: Custom allocation definition. - :type custom_allocation_definition: - ~microsoft.azure.management.provisioningservices.models.CustomAllocationDefinition + :type custom_allocation_definition: ~dps.models.CustomAllocationDefinition """ _validation = { @@ -82,11 +80,11 @@ class IndividualEnrollment(Model): } _attribute_map = { - 'capabilities': {'key': 'capabilities', 'type': 'DeviceCapabilities'}, 'registration_id': {'key': 'registrationId', 'type': 'str'}, 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'IndividualEnrollmentRegistrationState'}, + 'registration_state': {'key': 'registrationState', 'type': 'DeviceRegistrationState'}, 'attestation': {'key': 'attestation', 'type': 'AttestationMechanism'}, + 'capabilities': {'key': 'capabilities', 'type': 'DeviceCapabilities'}, 'iot_hub_host_name': {'key': 'iotHubHostName', 'type': 'str'}, 'initial_twin': {'key': 'initialTwin', 'type': 'InitialTwin'}, 'etag': {'key': 'etag', 'type': 'str'}, @@ -99,13 +97,13 @@ class IndividualEnrollment(Model): 'custom_allocation_definition': {'key': 'customAllocationDefinition', 'type': 'CustomAllocationDefinition'}, } - def __init__(self, registration_id, attestation, capabilities=None, device_id=None, iot_hub_host_name=None, initial_twin=None, etag=None, provisioning_status="enabled", reprovision_policy=None, allocation_policy=None, iot_hubs=None, custom_allocation_definition=None): - super(IndividualEnrollment, self).__init__() - self.capabilities = capabilities + def __init__(self, *, registration_id: str, attestation, device_id: str=None, capabilities=None, iot_hub_host_name: str=None, initial_twin=None, etag: str=None, provisioning_status="enabled", reprovision_policy=None, allocation_policy=None, iot_hubs=None, custom_allocation_definition=None, **kwargs) -> None: + super(IndividualEnrollment, self).__init__(**kwargs) self.registration_id = registration_id self.device_id = device_id self.registration_state = None self.attestation = attestation + self.capabilities = capabilities self.iot_hub_host_name = iot_hub_host_name self.initial_twin = initial_twin self.etag = etag diff --git a/azext_iot/sdk/dps/service/models/initial_twin.py b/azext_iot/sdk/dps/service/models/initial_twin.py new file mode 100644 index 000000000..069b74593 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/initial_twin.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class InitialTwin(Model): + """Initial device twin. Contains a subset of the properties of Twin. + + :param tags: Twin tags. + :type tags: ~dps.models.TwinCollection + :param properties: Twin desired properties. + :type properties: ~dps.models.InitialTwinProperties + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': 'TwinCollection'}, + 'properties': {'key': 'properties', 'type': 'InitialTwinProperties'}, + } + + def __init__(self, **kwargs): + super(InitialTwin, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.properties = kwargs.get('properties', None) diff --git a/azext_iot/sdk/dps/service/models/initial_twin_properties.py b/azext_iot/sdk/dps/service/models/initial_twin_properties.py new file mode 100644 index 000000000..dead116b8 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/initial_twin_properties.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class InitialTwinProperties(Model): + """Represents the initial properties that will be set on the device twin. + + :param desired: Gets and sets the InitialTwin desired properties. + :type desired: ~dps.models.TwinCollection + """ + + _attribute_map = { + 'desired': {'key': 'desired', 'type': 'TwinCollection'}, + } + + def __init__(self, **kwargs): + super(InitialTwinProperties, self).__init__(**kwargs) + self.desired = kwargs.get('desired', None) diff --git a/azext_iot/sdk/dps/models/initial_twin_properties.py b/azext_iot/sdk/dps/service/models/initial_twin_properties_py3.py similarity index 59% rename from azext_iot/sdk/dps/models/initial_twin_properties.py rename to azext_iot/sdk/dps/service/models/initial_twin_properties_py3.py index 955e82d8a..b3b86445e 100644 --- a/azext_iot/sdk/dps/models/initial_twin_properties.py +++ b/azext_iot/sdk/dps/service/models/initial_twin_properties_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -9,17 +13,16 @@ class InitialTwinProperties(Model): - """InitialTwinProperties. + """Represents the initial properties that will be set on the device twin. :param desired: Gets and sets the InitialTwin desired properties. - :type desired: - ~microsoft.azure.management.provisioningservices.models.TwinCollection + :type desired: ~dps.models.TwinCollection """ _attribute_map = { 'desired': {'key': 'desired', 'type': 'TwinCollection'}, } - def __init__(self, desired=None): - super(InitialTwinProperties, self).__init__() + def __init__(self, *, desired=None, **kwargs) -> None: + super(InitialTwinProperties, self).__init__(**kwargs) self.desired = desired diff --git a/azext_iot/sdk/dps/models/initial_twin.py b/azext_iot/sdk/dps/service/models/initial_twin_py3.py similarity index 66% rename from azext_iot/sdk/dps/models/initial_twin.py rename to azext_iot/sdk/dps/service/models/initial_twin_py3.py index e059973e6..91019fb75 100644 --- a/azext_iot/sdk/dps/models/initial_twin.py +++ b/azext_iot/sdk/dps/service/models/initial_twin_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -12,11 +16,9 @@ class InitialTwin(Model): """Initial device twin. Contains a subset of the properties of Twin. :param tags: Twin tags. - :type tags: - ~microsoft.azure.management.provisioningservices.models.TwinCollection + :type tags: ~dps.models.TwinCollection :param properties: Twin desired properties. - :type properties: - ~microsoft.azure.management.provisioningservices.models.InitialTwinProperties + :type properties: ~dps.models.InitialTwinProperties """ _attribute_map = { @@ -24,7 +26,7 @@ class InitialTwin(Model): 'properties': {'key': 'properties', 'type': 'InitialTwinProperties'}, } - def __init__(self, tags=None, properties=None): - super(InitialTwin, self).__init__() + def __init__(self, *, tags=None, properties=None, **kwargs) -> None: + super(InitialTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties diff --git a/azext_iot/sdk/dps/service/models/metadata.py b/azext_iot/sdk/dps/service/models/metadata.py new file mode 100644 index 000000000..560fdf217 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/metadata.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Metadata(Model): + """Metadata for the TwinCollection. + + :param last_updated: Last time the TwinCollection was updated + :type last_updated: datetime + :param last_updated_version: This SHOULD be null for Reported properties + metadata and MUST not be null for Desired properties metadata. + :type last_updated_version: long + """ + + _attribute_map = { + 'last_updated': {'key': 'lastUpdated', 'type': 'iso-8601'}, + 'last_updated_version': {'key': 'lastUpdatedVersion', 'type': 'long'}, + } + + def __init__(self, **kwargs): + super(Metadata, self).__init__(**kwargs) + self.last_updated = kwargs.get('last_updated', None) + self.last_updated_version = kwargs.get('last_updated_version', None) diff --git a/azext_iot/sdk/dps/models/metadata.py b/azext_iot/sdk/dps/service/models/metadata_py3.py similarity index 68% rename from azext_iot/sdk/dps/models/metadata.py rename to azext_iot/sdk/dps/service/models/metadata_py3.py index 5ade4a1ec..98715ac40 100644 --- a/azext_iot/sdk/dps/models/metadata.py +++ b/azext_iot/sdk/dps/service/models/metadata_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -9,9 +13,9 @@ class Metadata(Model): - """Metadata. + """Metadata for the TwinCollection. - :param last_updated: + :param last_updated: Last time the TwinCollection was updated :type last_updated: datetime :param last_updated_version: This SHOULD be null for Reported properties metadata and MUST not be null for Desired properties metadata. @@ -23,7 +27,7 @@ class Metadata(Model): 'last_updated_version': {'key': 'lastUpdatedVersion', 'type': 'long'}, } - def __init__(self, last_updated=None, last_updated_version=None): - super(Metadata, self).__init__() + def __init__(self, *, last_updated=None, last_updated_version: int=None, **kwargs) -> None: + super(Metadata, self).__init__(**kwargs) self.last_updated = last_updated self.last_updated_version = last_updated_version diff --git a/azext_iot/sdk/dps/service/models/provisioning_service_error_details.py b/azext_iot/sdk/dps/service/models/provisioning_service_error_details.py new file mode 100644 index 000000000..e58db7faf --- /dev/null +++ b/azext_iot/sdk/dps/service/models/provisioning_service_error_details.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ProvisioningServiceErrorDetails(Model): + """Contains the properties of an error returned by the Azure IoT Hub + Provisioning Service. + + :param error_code: + :type error_code: int + :param tracking_id: + :type tracking_id: str + :param message: + :type message: str + :param info: + :type info: dict[str, str] + :param timestamp_utc: + :type timestamp_utc: datetime + """ + + _attribute_map = { + 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'tracking_id': {'key': 'trackingId', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'info': {'key': 'info', 'type': '{str}'}, + 'timestamp_utc': {'key': 'timestampUtc', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ProvisioningServiceErrorDetails, self).__init__(**kwargs) + self.error_code = kwargs.get('error_code', None) + self.tracking_id = kwargs.get('tracking_id', None) + self.message = kwargs.get('message', None) + self.info = kwargs.get('info', None) + self.timestamp_utc = kwargs.get('timestamp_utc', None) + + +class ProvisioningServiceErrorDetailsException(HttpOperationError): + """Server responsed with exception of type: 'ProvisioningServiceErrorDetails'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ProvisioningServiceErrorDetailsException, self).__init__(deserialize, response, 'ProvisioningServiceErrorDetails', *args) diff --git a/azext_iot/sdk/dps/models/provisioning_service_error_details.py b/azext_iot/sdk/dps/service/models/provisioning_service_error_details_py3.py similarity index 77% rename from azext_iot/sdk/dps/models/provisioning_service_error_details.py rename to azext_iot/sdk/dps/service/models/provisioning_service_error_details_py3.py index d1e6743bd..2c1411312 100644 --- a/azext_iot/sdk/dps/models/provisioning_service_error_details.py +++ b/azext_iot/sdk/dps/service/models/provisioning_service_error_details_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -10,7 +14,8 @@ class ProvisioningServiceErrorDetails(Model): - """ProvisioningServiceErrorDetails. + """Contains the properties of an error returned by the Azure IoT Hub + Provisioning Service. :param error_code: :type error_code: int @@ -32,8 +37,8 @@ class ProvisioningServiceErrorDetails(Model): 'timestamp_utc': {'key': 'timestampUtc', 'type': 'iso-8601'}, } - def __init__(self, error_code=None, tracking_id=None, message=None, info=None, timestamp_utc=None): - super(ProvisioningServiceErrorDetails, self).__init__() + def __init__(self, *, error_code: int=None, tracking_id: str=None, message: str=None, info=None, timestamp_utc=None, **kwargs) -> None: + super(ProvisioningServiceErrorDetails, self).__init__(**kwargs) self.error_code = error_code self.tracking_id = tracking_id self.message = message diff --git a/azext_iot/sdk/dps/service/models/query_specification.py b/azext_iot/sdk/dps/service/models/query_specification.py new file mode 100644 index 000000000..378002dd4 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/query_specification.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QuerySpecification(Model): + """A Json query request. + + All required parameters must be populated in order to send to Azure. + + :param query: Required. The query. + :type query: str + """ + + _validation = { + 'query': {'required': True}, + } + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(QuerySpecification, self).__init__(**kwargs) + self.query = kwargs.get('query', None) diff --git a/azext_iot/sdk/dps/models/query_specification.py b/azext_iot/sdk/dps/service/models/query_specification_py3.py similarity index 61% rename from azext_iot/sdk/dps/models/query_specification.py rename to azext_iot/sdk/dps/service/models/query_specification_py3.py index 990dbf1e3..290bd23a2 100644 --- a/azext_iot/sdk/dps/models/query_specification.py +++ b/azext_iot/sdk/dps/service/models/query_specification_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,7 +15,9 @@ class QuerySpecification(Model): """A Json query request. - :param query: The query. + All required parameters must be populated in order to send to Azure. + + :param query: Required. The query. :type query: str """ @@ -23,6 +29,6 @@ class QuerySpecification(Model): 'query': {'key': 'query', 'type': 'str'}, } - def __init__(self, query): - super(QuerySpecification, self).__init__() + def __init__(self, *, query: str, **kwargs) -> None: + super(QuerySpecification, self).__init__(**kwargs) self.query = query diff --git a/azext_iot/sdk/dps/service/models/reprovision_policy.py b/azext_iot/sdk/dps/service/models/reprovision_policy.py new file mode 100644 index 000000000..92e777bf6 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/reprovision_policy.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReprovisionPolicy(Model): + """The behavior of the service when a device is re-provisioned to an IoT hub. + + All required parameters must be populated in order to send to Azure. + + :param update_hub_assignment: Required. When set to true (default), the + Device Provisioning Service will evaluate the device's IoT Hub assignment + and update it if necessary for any provisioning requests beyond the first + from a given device. If set to false, the device will stay assigned to its + current IoT hub. Default value: True . + :type update_hub_assignment: bool + :param migrate_device_data: Required. When set to true (default), the + Device Provisioning Service will migrate the device's data (twin, device + capabilities, and device ID) from one IoT hub to another during an IoT hub + assignment update. If set to false, the Device Provisioning Service will + reset the device's data to the initial desired configuration stored in the + corresponding enrollment list. Default value: True . + :type migrate_device_data: bool + """ + + _validation = { + 'update_hub_assignment': {'required': True}, + 'migrate_device_data': {'required': True}, + } + + _attribute_map = { + 'update_hub_assignment': {'key': 'updateHubAssignment', 'type': 'bool'}, + 'migrate_device_data': {'key': 'migrateDeviceData', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(ReprovisionPolicy, self).__init__(**kwargs) + self.update_hub_assignment = kwargs.get('update_hub_assignment', True) + self.migrate_device_data = kwargs.get('migrate_device_data', True) diff --git a/azext_iot/sdk/dps/models/reprovision_policy.py b/azext_iot/sdk/dps/service/models/reprovision_policy_py3.py similarity index 60% rename from azext_iot/sdk/dps/models/reprovision_policy.py rename to azext_iot/sdk/dps/service/models/reprovision_policy_py3.py index dafaa1ee0..3a1403f2e 100644 --- a/azext_iot/sdk/dps/models/reprovision_policy.py +++ b/azext_iot/sdk/dps/service/models/reprovision_policy_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,14 +15,16 @@ class ReprovisionPolicy(Model): """The behavior of the service when a device is re-provisioned to an IoT hub. - :param update_hub_assignment: When set to true (default), the Device - Provisioning Service will evaluate the device's IoT Hub assignment and - update it if necessary for any provisioning requests beyond the first from - a given device. If set to false, the device will stay assigned to its + All required parameters must be populated in order to send to Azure. + + :param update_hub_assignment: Required. When set to true (default), the + Device Provisioning Service will evaluate the device's IoT Hub assignment + and update it if necessary for any provisioning requests beyond the first + from a given device. If set to false, the device will stay assigned to its current IoT hub. Default value: True . :type update_hub_assignment: bool - :param migrate_device_data: When set to true (default), the Device - Provisioning Service will migrate the device's data (twin, device + :param migrate_device_data: Required. When set to true (default), the + Device Provisioning Service will migrate the device's data (twin, device capabilities, and device ID) from one IoT hub to another during an IoT hub assignment update. If set to false, the Device Provisioning Service will reset the device's data to the initial desired configuration stored in the @@ -36,7 +42,7 @@ class ReprovisionPolicy(Model): 'migrate_device_data': {'key': 'migrateDeviceData', 'type': 'bool'}, } - def __init__(self, update_hub_assignment=True, migrate_device_data=True): - super(ReprovisionPolicy, self).__init__() + def __init__(self, *, update_hub_assignment: bool=True, migrate_device_data: bool=True, **kwargs) -> None: + super(ReprovisionPolicy, self).__init__(**kwargs) self.update_hub_assignment = update_hub_assignment self.migrate_device_data = migrate_device_data diff --git a/azext_iot/sdk/dps/service/models/symmetric_key_attestation.py b/azext_iot/sdk/dps/service/models/symmetric_key_attestation.py new file mode 100644 index 000000000..6e94284c9 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/symmetric_key_attestation.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SymmetricKeyAttestation(Model): + """Attestation via SymmetricKey. + + :param primary_key: Primary symmetric key. + :type primary_key: str + :param secondary_key: Secondary symmetric key. + :type secondary_key: str + """ + + _attribute_map = { + 'primary_key': {'key': 'primaryKey', 'type': 'str'}, + 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SymmetricKeyAttestation, self).__init__(**kwargs) + self.primary_key = kwargs.get('primary_key', None) + self.secondary_key = kwargs.get('secondary_key', None) diff --git a/azext_iot/sdk/dps/models/symmetric_key_attestation.py b/azext_iot/sdk/dps/service/models/symmetric_key_attestation_py3.py similarity index 72% rename from azext_iot/sdk/dps/models/symmetric_key_attestation.py rename to azext_iot/sdk/dps/service/models/symmetric_key_attestation_py3.py index 28a1ef96a..b2efe3ce4 100644 --- a/azext_iot/sdk/dps/models/symmetric_key_attestation.py +++ b/azext_iot/sdk/dps/service/models/symmetric_key_attestation_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -22,7 +26,7 @@ class SymmetricKeyAttestation(Model): 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, } - def __init__(self, primary_key=None, secondary_key=None): - super(SymmetricKeyAttestation, self).__init__() + def __init__(self, *, primary_key: str=None, secondary_key: str=None, **kwargs) -> None: + super(SymmetricKeyAttestation, self).__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key diff --git a/azext_iot/sdk/dps/service/models/tpm_attestation.py b/azext_iot/sdk/dps/service/models/tpm_attestation.py new file mode 100644 index 000000000..1643e80c9 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/tpm_attestation.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TpmAttestation(Model): + """Attestation via TPM. + + All required parameters must be populated in order to send to Azure. + + :param endorsement_key: Required. + :type endorsement_key: str + :param storage_root_key: + :type storage_root_key: str + """ + + _validation = { + 'endorsement_key': {'required': True}, + } + + _attribute_map = { + 'endorsement_key': {'key': 'endorsementKey', 'type': 'str'}, + 'storage_root_key': {'key': 'storageRootKey', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(TpmAttestation, self).__init__(**kwargs) + self.endorsement_key = kwargs.get('endorsement_key', None) + self.storage_root_key = kwargs.get('storage_root_key', None) diff --git a/azext_iot/sdk/dps/models/tpm_attestation.py b/azext_iot/sdk/dps/service/models/tpm_attestation_py3.py similarity index 66% rename from azext_iot/sdk/dps/models/tpm_attestation.py rename to azext_iot/sdk/dps/service/models/tpm_attestation_py3.py index aaf7e8b9f..648b364cc 100644 --- a/azext_iot/sdk/dps/models/tpm_attestation.py +++ b/azext_iot/sdk/dps/service/models/tpm_attestation_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,7 +15,9 @@ class TpmAttestation(Model): """Attestation via TPM. - :param endorsement_key: + All required parameters must be populated in order to send to Azure. + + :param endorsement_key: Required. :type endorsement_key: str :param storage_root_key: :type storage_root_key: str @@ -26,7 +32,7 @@ class TpmAttestation(Model): 'storage_root_key': {'key': 'storageRootKey', 'type': 'str'}, } - def __init__(self, endorsement_key, storage_root_key=None): - super(TpmAttestation, self).__init__() + def __init__(self, *, endorsement_key: str, storage_root_key: str=None, **kwargs) -> None: + super(TpmAttestation, self).__init__(**kwargs) self.endorsement_key = endorsement_key self.storage_root_key = storage_root_key diff --git a/azext_iot/sdk/dps/service/models/twin_collection.py b/azext_iot/sdk/dps/service/models/twin_collection.py new file mode 100644 index 000000000..3ead028fc --- /dev/null +++ b/azext_iot/sdk/dps/service/models/twin_collection.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TwinCollection(Model): + """Represents a collection of properties within a Twin. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param version: Version of the TwinCollection + :type version: long + :param count: Number of properties in the TwinCollection + :type count: int + :param metadata: Metadata for the TwinCollection + :type metadata: ~dps.models.Metadata + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'version': {'key': 'version', 'type': 'long'}, + 'count': {'key': 'count', 'type': 'int'}, + 'metadata': {'key': 'metadata', 'type': 'Metadata'}, + } + + def __init__(self, **kwargs): + super(TwinCollection, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.version = kwargs.get('version', None) + self.count = kwargs.get('count', None) + self.metadata = kwargs.get('metadata', None) diff --git a/azext_iot/sdk/dps/models/twin_collection.py b/azext_iot/sdk/dps/service/models/twin_collection_py3.py similarity index 62% rename from azext_iot/sdk/dps/models/twin_collection.py rename to azext_iot/sdk/dps/service/models/twin_collection_py3.py index b3cf49987..232f7dedd 100644 --- a/azext_iot/sdk/dps/models/twin_collection.py +++ b/azext_iot/sdk/dps/service/models/twin_collection_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -9,18 +13,17 @@ class TwinCollection(Model): - """TwinCollection. + """Represents a collection of properties within a Twin. :param additional_properties: Unmatched properties from the message are deserialized this collection :type additional_properties: dict[str, object] - :param version: + :param version: Version of the TwinCollection :type version: long - :param count: + :param count: Number of properties in the TwinCollection :type count: int - :param metadata: - :type metadata: - ~microsoft.azure.management.provisioningservices.models.Metadata + :param metadata: Metadata for the TwinCollection + :type metadata: ~dps.models.Metadata """ _attribute_map = { @@ -30,8 +33,8 @@ class TwinCollection(Model): 'metadata': {'key': 'metadata', 'type': 'Metadata'}, } - def __init__(self, additional_properties=None, version=None, count=None, metadata=None): - super(TwinCollection, self).__init__() + def __init__(self, *, additional_properties=None, version: int=None, count: int=None, metadata=None, **kwargs) -> None: + super(TwinCollection, self).__init__(**kwargs) self.additional_properties = additional_properties self.version = version self.count = count diff --git a/azext_iot/sdk/dps/service/models/x509_attestation.py b/azext_iot/sdk/dps/service/models/x509_attestation.py new file mode 100644 index 000000000..2ffedb0cb --- /dev/null +++ b/azext_iot/sdk/dps/service/models/x509_attestation.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class X509Attestation(Model): + """Attestation via X509. + + :param client_certificates: + :type client_certificates: ~dps.models.X509Certificates + :param signing_certificates: + :type signing_certificates: ~dps.models.X509Certificates + :param ca_references: + :type ca_references: ~dps.models.X509CAReferences + """ + + _attribute_map = { + 'client_certificates': {'key': 'clientCertificates', 'type': 'X509Certificates'}, + 'signing_certificates': {'key': 'signingCertificates', 'type': 'X509Certificates'}, + 'ca_references': {'key': 'caReferences', 'type': 'X509CAReferences'}, + } + + def __init__(self, **kwargs): + super(X509Attestation, self).__init__(**kwargs) + self.client_certificates = kwargs.get('client_certificates', None) + self.signing_certificates = kwargs.get('signing_certificates', None) + self.ca_references = kwargs.get('ca_references', None) diff --git a/azext_iot/sdk/dps/models/x509_attestation.py b/azext_iot/sdk/dps/service/models/x509_attestation_py3.py similarity index 65% rename from azext_iot/sdk/dps/models/x509_attestation.py rename to azext_iot/sdk/dps/service/models/x509_attestation_py3.py index 56cd4d968..46184475c 100644 --- a/azext_iot/sdk/dps/models/x509_attestation.py +++ b/azext_iot/sdk/dps/service/models/x509_attestation_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -12,14 +16,11 @@ class X509Attestation(Model): """Attestation via X509. :param client_certificates: - :type client_certificates: - ~microsoft.azure.management.provisioningservices.models.X509Certificates + :type client_certificates: ~dps.models.X509Certificates :param signing_certificates: - :type signing_certificates: - ~microsoft.azure.management.provisioningservices.models.X509Certificates + :type signing_certificates: ~dps.models.X509Certificates :param ca_references: - :type ca_references: - ~microsoft.azure.management.provisioningservices.models.X509CAReferences + :type ca_references: ~dps.models.X509CAReferences """ _attribute_map = { @@ -28,8 +29,8 @@ class X509Attestation(Model): 'ca_references': {'key': 'caReferences', 'type': 'X509CAReferences'}, } - def __init__(self, client_certificates=None, signing_certificates=None, ca_references=None): - super(X509Attestation, self).__init__() + def __init__(self, *, client_certificates=None, signing_certificates=None, ca_references=None, **kwargs) -> None: + super(X509Attestation, self).__init__(**kwargs) self.client_certificates = client_certificates self.signing_certificates = signing_certificates self.ca_references = ca_references diff --git a/azext_iot/sdk/dps/service/models/x509_ca_references.py b/azext_iot/sdk/dps/service/models/x509_ca_references.py new file mode 100644 index 000000000..be2306bd8 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/x509_ca_references.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class X509CAReferences(Model): + """Primary and secondary CA references. + + :param primary: + :type primary: str + :param secondary: + :type secondary: str + """ + + _attribute_map = { + 'primary': {'key': 'primary', 'type': 'str'}, + 'secondary': {'key': 'secondary', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(X509CAReferences, self).__init__(**kwargs) + self.primary = kwargs.get('primary', None) + self.secondary = kwargs.get('secondary', None) diff --git a/azext_iot/sdk/dps/models/x509_ca_references.py b/azext_iot/sdk/dps/service/models/x509_ca_references_py3.py similarity index 71% rename from azext_iot/sdk/dps/models/x509_ca_references.py rename to azext_iot/sdk/dps/service/models/x509_ca_references_py3.py index b08341f52..4a85172ae 100644 --- a/azext_iot/sdk/dps/models/x509_ca_references.py +++ b/azext_iot/sdk/dps/service/models/x509_ca_references_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -22,7 +26,7 @@ class X509CAReferences(Model): 'secondary': {'key': 'secondary', 'type': 'str'}, } - def __init__(self, primary=None, secondary=None): - super(X509CAReferences, self).__init__() + def __init__(self, *, primary: str=None, secondary: str=None, **kwargs) -> None: + super(X509CAReferences, self).__init__(**kwargs) self.primary = primary self.secondary = secondary diff --git a/azext_iot/sdk/dps/service/models/x509_certificate_info.py b/azext_iot/sdk/dps/service/models/x509_certificate_info.py new file mode 100644 index 000000000..2eb783782 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/x509_certificate_info.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class X509CertificateInfo(Model): + """X509 certificate info. + + All required parameters must be populated in order to send to Azure. + + :param subject_name: Required. + :type subject_name: str + :param sha1_thumbprint: Required. + :type sha1_thumbprint: str + :param sha256_thumbprint: Required. + :type sha256_thumbprint: str + :param issuer_name: Required. + :type issuer_name: str + :param not_before_utc: Required. + :type not_before_utc: datetime + :param not_after_utc: Required. + :type not_after_utc: datetime + :param serial_number: Required. + :type serial_number: str + :param version: Required. + :type version: int + """ + + _validation = { + 'subject_name': {'required': True}, + 'sha1_thumbprint': {'required': True}, + 'sha256_thumbprint': {'required': True}, + 'issuer_name': {'required': True}, + 'not_before_utc': {'required': True}, + 'not_after_utc': {'required': True}, + 'serial_number': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'subject_name': {'key': 'subjectName', 'type': 'str'}, + 'sha1_thumbprint': {'key': 'sha1Thumbprint', 'type': 'str'}, + 'sha256_thumbprint': {'key': 'sha256Thumbprint', 'type': 'str'}, + 'issuer_name': {'key': 'issuerName', 'type': 'str'}, + 'not_before_utc': {'key': 'notBeforeUtc', 'type': 'iso-8601'}, + 'not_after_utc': {'key': 'notAfterUtc', 'type': 'iso-8601'}, + 'serial_number': {'key': 'serialNumber', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(X509CertificateInfo, self).__init__(**kwargs) + self.subject_name = kwargs.get('subject_name', None) + self.sha1_thumbprint = kwargs.get('sha1_thumbprint', None) + self.sha256_thumbprint = kwargs.get('sha256_thumbprint', None) + self.issuer_name = kwargs.get('issuer_name', None) + self.not_before_utc = kwargs.get('not_before_utc', None) + self.not_after_utc = kwargs.get('not_after_utc', None) + self.serial_number = kwargs.get('serial_number', None) + self.version = kwargs.get('version', None) diff --git a/azext_iot/sdk/dps/models/x509_certificate_info.py b/azext_iot/sdk/dps/service/models/x509_certificate_info_py3.py similarity index 71% rename from azext_iot/sdk/dps/models/x509_certificate_info.py rename to azext_iot/sdk/dps/service/models/x509_certificate_info_py3.py index 1d0c92ab1..dc1ebb97f 100644 --- a/azext_iot/sdk/dps/models/x509_certificate_info.py +++ b/azext_iot/sdk/dps/service/models/x509_certificate_info_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -11,21 +15,23 @@ class X509CertificateInfo(Model): """X509 certificate info. - :param subject_name: + All required parameters must be populated in order to send to Azure. + + :param subject_name: Required. :type subject_name: str - :param sha1_thumbprint: + :param sha1_thumbprint: Required. :type sha1_thumbprint: str - :param sha256_thumbprint: + :param sha256_thumbprint: Required. :type sha256_thumbprint: str - :param issuer_name: + :param issuer_name: Required. :type issuer_name: str - :param not_before_utc: + :param not_before_utc: Required. :type not_before_utc: datetime - :param not_after_utc: + :param not_after_utc: Required. :type not_after_utc: datetime - :param serial_number: + :param serial_number: Required. :type serial_number: str - :param version: + :param version: Required. :type version: int """ @@ -51,8 +57,8 @@ class X509CertificateInfo(Model): 'version': {'key': 'version', 'type': 'int'}, } - def __init__(self, subject_name, sha1_thumbprint, sha256_thumbprint, issuer_name, not_before_utc, not_after_utc, serial_number, version): - super(X509CertificateInfo, self).__init__() + def __init__(self, *, subject_name: str, sha1_thumbprint: str, sha256_thumbprint: str, issuer_name: str, not_before_utc, not_after_utc, serial_number: str, version: int, **kwargs) -> None: + super(X509CertificateInfo, self).__init__(**kwargs) self.subject_name = subject_name self.sha1_thumbprint = sha1_thumbprint self.sha256_thumbprint = sha256_thumbprint diff --git a/azext_iot/sdk/dps/service/models/x509_certificate_with_info.py b/azext_iot/sdk/dps/service/models/x509_certificate_with_info.py new file mode 100644 index 000000000..36bc3d09e --- /dev/null +++ b/azext_iot/sdk/dps/service/models/x509_certificate_with_info.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class X509CertificateWithInfo(Model): + """Certificate and Certificate info. + + :param certificate: + :type certificate: str + :param info: + :type info: ~dps.models.X509CertificateInfo + """ + + _attribute_map = { + 'certificate': {'key': 'certificate', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'X509CertificateInfo'}, + } + + def __init__(self, **kwargs): + super(X509CertificateWithInfo, self).__init__(**kwargs) + self.certificate = kwargs.get('certificate', None) + self.info = kwargs.get('info', None) diff --git a/azext_iot/sdk/dps/models/x509_certificate_with_info.py b/azext_iot/sdk/dps/service/models/x509_certificate_with_info_py3.py similarity index 67% rename from azext_iot/sdk/dps/models/x509_certificate_with_info.py rename to azext_iot/sdk/dps/service/models/x509_certificate_with_info_py3.py index 0704b6e4a..a54d66939 100644 --- a/azext_iot/sdk/dps/models/x509_certificate_with_info.py +++ b/azext_iot/sdk/dps/service/models/x509_certificate_with_info_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -14,8 +18,7 @@ class X509CertificateWithInfo(Model): :param certificate: :type certificate: str :param info: - :type info: - ~microsoft.azure.management.provisioningservices.models.X509CertificateInfo + :type info: ~dps.models.X509CertificateInfo """ _attribute_map = { @@ -23,7 +26,7 @@ class X509CertificateWithInfo(Model): 'info': {'key': 'info', 'type': 'X509CertificateInfo'}, } - def __init__(self, certificate=None, info=None): - super(X509CertificateWithInfo, self).__init__() + def __init__(self, *, certificate: str=None, info=None, **kwargs) -> None: + super(X509CertificateWithInfo, self).__init__(**kwargs) self.certificate = certificate self.info = info diff --git a/azext_iot/sdk/dps/service/models/x509_certificates.py b/azext_iot/sdk/dps/service/models/x509_certificates.py new file mode 100644 index 000000000..c549e0da2 --- /dev/null +++ b/azext_iot/sdk/dps/service/models/x509_certificates.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class X509Certificates(Model): + """Primary and secondary certificates. + + :param primary: + :type primary: ~dps.models.X509CertificateWithInfo + :param secondary: + :type secondary: ~dps.models.X509CertificateWithInfo + """ + + _attribute_map = { + 'primary': {'key': 'primary', 'type': 'X509CertificateWithInfo'}, + 'secondary': {'key': 'secondary', 'type': 'X509CertificateWithInfo'}, + } + + def __init__(self, **kwargs): + super(X509Certificates, self).__init__(**kwargs) + self.primary = kwargs.get('primary', None) + self.secondary = kwargs.get('secondary', None) diff --git a/azext_iot/sdk/dps/models/x509_certificates.py b/azext_iot/sdk/dps/service/models/x509_certificates_py3.py similarity index 64% rename from azext_iot/sdk/dps/models/x509_certificates.py rename to azext_iot/sdk/dps/service/models/x509_certificates_py3.py index 8845b060c..08d848954 100644 --- a/azext_iot/sdk/dps/models/x509_certificates.py +++ b/azext_iot/sdk/dps/service/models/x509_certificates_py3.py @@ -1,5 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. @@ -12,11 +16,9 @@ class X509Certificates(Model): """Primary and secondary certificates. :param primary: - :type primary: - ~microsoft.azure.management.provisioningservices.models.X509CertificateWithInfo + :type primary: ~dps.models.X509CertificateWithInfo :param secondary: - :type secondary: - ~microsoft.azure.management.provisioningservices.models.X509CertificateWithInfo + :type secondary: ~dps.models.X509CertificateWithInfo """ _attribute_map = { @@ -24,7 +26,7 @@ class X509Certificates(Model): 'secondary': {'key': 'secondary', 'type': 'X509CertificateWithInfo'}, } - def __init__(self, primary=None, secondary=None): - super(X509Certificates, self).__init__() + def __init__(self, *, primary=None, secondary=None, **kwargs) -> None: + super(X509Certificates, self).__init__(**kwargs) self.primary = primary self.secondary = secondary diff --git a/azext_iot/sdk/dps/service/provisioning_service_client.py b/azext_iot/sdk/dps/service/provisioning_service_client.py new file mode 100644 index 000000000..a7a0fa314 --- /dev/null +++ b/azext_iot/sdk/dps/service/provisioning_service_client.py @@ -0,0 +1,1023 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from msrest.pipeline import ClientRawResponse +import uuid +from . import models +from ....constants import USER_AGENT + + +class ProvisioningServiceClientConfiguration(AzureConfiguration): + """Configuration for ProvisioningServiceClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://your-dps.azure-devices-provisioning.net' + + super(ProvisioningServiceClientConfiguration, self).__init__(base_url) + + self.add_user_agent('provisioningserviceclient/{}'.format(VERSION)) + self.add_user_agent(USER_AGENT) # @c-ryan-k - added CLI UA string + + self.credentials = credentials + + +class ProvisioningServiceClient(SDKClient): + """API for service operations with the Azure IoT Hub Device Provisioning Service + + :ivar config: Configuration for client. + :vartype config: ProvisioningServiceClientConfiguration + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = ProvisioningServiceClientConfiguration(credentials, base_url) + super(ProvisioningServiceClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2019-03-31' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + + def get_individual_enrollment( + self, id, custom_headers=None, raw=False, **operation_config): + """Get a device enrollment record. + + :param id: Registration ID. + :type id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: IndividualEnrollment or ClientRawResponse if raw=true + :rtype: ~dps.models.IndividualEnrollment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.get_individual_enrollment.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('IndividualEnrollment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_individual_enrollment.metadata = {'url': '/enrollments/{id}'} + + def create_or_update_individual_enrollment( + self, id, enrollment, if_match=None, custom_headers=None, raw=False, **operation_config): + """Create or update a device enrollment record. + + :param id: The registration ID is alphanumeric, lowercase, and may + contain hyphens. + :type id: str + :param enrollment: The device enrollment record. + :type enrollment: ~dps.models.IndividualEnrollment + :param if_match: The ETag of the enrollment record. + :type if_match: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: IndividualEnrollment or ClientRawResponse if raw=true + :rtype: ~dps.models.IndividualEnrollment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.create_or_update_individual_enrollment.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(enrollment, 'IndividualEnrollment') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('IndividualEnrollment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_individual_enrollment.metadata = {'url': '/enrollments/{id}'} + + def delete_individual_enrollment( + self, id, if_match=None, custom_headers=None, raw=False, **operation_config): + """Delete a device enrollment record. + + :param id: Registration ID. + :type id: str + :param if_match: The ETag of the enrollment record. + :type if_match: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.delete_individual_enrollment.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_individual_enrollment.metadata = {'url': '/enrollments/{id}'} + + def get_enrollment_group( + self, id, custom_headers=None, raw=False, **operation_config): + """Get a device enrollment group. + + :param id: Enrollment group ID. + :type id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: EnrollmentGroup or ClientRawResponse if raw=true + :rtype: ~dps.models.EnrollmentGroup or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.get_enrollment_group.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('EnrollmentGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_enrollment_group.metadata = {'url': '/enrollmentGroups/{id}'} + + def create_or_update_enrollment_group( + self, id, enrollment_group, if_match=None, custom_headers=None, raw=False, **operation_config): + """Create or update a device enrollment group. + + :param id: Enrollment group ID. + :type id: str + :param enrollment_group: The device enrollment group. + :type enrollment_group: ~dps.models.EnrollmentGroup + :param if_match: The ETag of the enrollment record. + :type if_match: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: EnrollmentGroup or ClientRawResponse if raw=true + :rtype: ~dps.models.EnrollmentGroup or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.create_or_update_enrollment_group.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(enrollment_group, 'EnrollmentGroup') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('EnrollmentGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_enrollment_group.metadata = {'url': '/enrollmentGroups/{id}'} + + def delete_enrollment_group( + self, id, if_match=None, custom_headers=None, raw=False, **operation_config): + """Delete a device enrollment group. + + :param id: Enrollment group ID. + :type id: str + :param if_match: The ETag of the enrollment group record. + :type if_match: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.delete_enrollment_group.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_enrollment_group.metadata = {'url': '/enrollmentGroups/{id}'} + + def get_device_registration_state( + self, id, custom_headers=None, raw=False, **operation_config): + """Gets the device registration state. + + :param id: Registration ID. + :type id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: DeviceRegistrationState or ClientRawResponse if raw=true + :rtype: ~dps.models.DeviceRegistrationState or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.get_device_registration_state.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('DeviceRegistrationState', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_device_registration_state.metadata = {'url': '/registrations/{id}'} + + def delete_device_registration_state( + self, id, if_match=None, custom_headers=None, raw=False, **operation_config): + """Deletes the device registration. + + :param id: Registration ID. + :type id: str + :param if_match: The ETag of the registration status record. + :type if_match: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.delete_device_registration_state.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_device_registration_state.metadata = {'url': '/registrations/{id}'} + + def query_individual_enrollments( + self, query, x_ms_max_item_count=None, x_ms_continuation=None, custom_headers=None, raw=False, **operation_config): + """Query the device enrollment records. + + :param query: The query. + :type query: str + :param x_ms_max_item_count: Page size + :type x_ms_max_item_count: int + :param x_ms_continuation: Continuation token + :type x_ms_continuation: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: list[~dps.models.IndividualEnrollment] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + query_specification = models.QuerySpecification(query=query) + + api_version = "2019-03-31" + + # Construct URL + url = self.query_individual_enrollments.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if x_ms_max_item_count is not None: + header_parameters['x-ms-max-item-count'] = self._serialize.header("x_ms_max_item_count", x_ms_max_item_count, 'int') + if x_ms_continuation is not None: + header_parameters['x-ms-continuation'] = self._serialize.header("x_ms_continuation", x_ms_continuation, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(query_specification, 'QuerySpecification') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + header_dict = {} + + if response.status_code == 200: + deserialized = self._deserialize('[IndividualEnrollment]', response) + header_dict = { + 'x-ms-continuation': 'str', + 'x-ms-max-item-count': 'int', + 'x-ms-item-type': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + query_individual_enrollments.metadata = {'url': '/enrollments/query'} + + def get_individual_enrollment_attestation_mechanism( + self, id, custom_headers=None, raw=False, **operation_config): + """Get the attestation mechanism in the device enrollment record. + + :param id: Registration ID. + :type id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AttestationMechanism or ClientRawResponse if raw=true + :rtype: ~dps.models.AttestationMechanism or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.get_individual_enrollment_attestation_mechanism.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('AttestationMechanism', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_individual_enrollment_attestation_mechanism.metadata = {'url': '/enrollments/{id}/attestationmechanism'} + + def run_bulk_individual_enrollment_operation( + self, enrollments, mode, custom_headers=None, raw=False, **operation_config): + """Bulk device enrollment operation with maximum of 10 enrollments. + + :param enrollments: Enrollment items + :type enrollments: list[~dps.models.IndividualEnrollment] + :param mode: Operation mode. Possible values include: 'create', + 'update', 'updateIfMatchETag', 'delete' + :type mode: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: BulkEnrollmentOperationResult or ClientRawResponse if + raw=true + :rtype: ~dps.models.BulkEnrollmentOperationResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + bulk_operation = models.BulkEnrollmentOperation(enrollments=enrollments, mode=mode) + + api_version = "2019-03-31" + + # Construct URL + url = self.run_bulk_individual_enrollment_operation.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(bulk_operation, 'BulkEnrollmentOperation') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('BulkEnrollmentOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + run_bulk_individual_enrollment_operation.metadata = {'url': '/enrollments'} + + def query_enrollment_groups( + self, query, x_ms_max_item_count=None, x_ms_continuation=None, custom_headers=None, raw=False, **operation_config): + """Query the device enrollment groups. + + :param query: The query. + :type query: str + :param x_ms_max_item_count: Page size + :type x_ms_max_item_count: int + :param x_ms_continuation: Continuation token + :type x_ms_continuation: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: list[~dps.models.EnrollmentGroup] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + query_specification = models.QuerySpecification(query=query) + + api_version = "2019-03-31" + + # Construct URL + url = self.query_enrollment_groups.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if x_ms_max_item_count is not None: + header_parameters['x-ms-max-item-count'] = self._serialize.header("x_ms_max_item_count", x_ms_max_item_count, 'int') + if x_ms_continuation is not None: + header_parameters['x-ms-continuation'] = self._serialize.header("x_ms_continuation", x_ms_continuation, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(query_specification, 'QuerySpecification') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + header_dict = {} + + if response.status_code == 200: + deserialized = self._deserialize('[EnrollmentGroup]', response) + header_dict = { + 'x-ms-continuation': 'str', + 'x-ms-max-item-count': 'int', + 'x-ms-item-type': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + query_enrollment_groups.metadata = {'url': '/enrollmentGroups/query'} + + def get_enrollment_group_attestation_mechanism( + self, id, custom_headers=None, raw=False, **operation_config): + """Get the attestation mechanism in the device enrollment group record. + + :param id: Enrollment group ID + :type id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AttestationMechanism or ClientRawResponse if raw=true + :rtype: ~dps.models.AttestationMechanism or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.get_enrollment_group_attestation_mechanism.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('AttestationMechanism', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_enrollment_group_attestation_mechanism.metadata = {'url': '/enrollmentGroups/{id}/attestationmechanism'} + + def run_bulk_enrollment_group_operation( + self, enrollment_groups, mode, custom_headers=None, raw=False, **operation_config): + """Bulk device enrollment group operation with maximum of 10 groups. + + :param enrollment_groups: Enrollment items + :type enrollment_groups: list[~dps.models.EnrollmentGroup] + :param mode: Operation mode. Possible values include: 'create', + 'update', 'updateIfMatchETag', 'delete' + :type mode: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: BulkEnrollmentGroupOperationResult or ClientRawResponse if + raw=true + :rtype: ~dps.models.BulkEnrollmentGroupOperationResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + bulk_operation = models.BulkEnrollmentGroupOperation(enrollment_groups=enrollment_groups, mode=mode) + + api_version = "2019-03-31" + + # Construct URL + url = self.run_bulk_enrollment_group_operation.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(bulk_operation, 'BulkEnrollmentGroupOperation') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('BulkEnrollmentGroupOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + run_bulk_enrollment_group_operation.metadata = {'url': '/enrollmentGroups'} + + def query_device_registration_states( + self, id, x_ms_max_item_count=None, x_ms_continuation=None, custom_headers=None, raw=False, **operation_config): + """Gets the registration state of devices in this enrollmentGroup. + + :param id: Enrollment group ID. + :type id: str + :param x_ms_max_item_count: pageSize + :type x_ms_max_item_count: int + :param x_ms_continuation: continuation token + :type x_ms_continuation: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: list[~dps.models.DeviceRegistrationState] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ProvisioningServiceErrorDetailsException` + """ + api_version = "2019-03-31" + + # Construct URL + url = self.query_device_registration_states.metadata['url'] + path_format_arguments = { + 'id': self._serialize.url("id", id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if x_ms_max_item_count is not None: + header_parameters['x-ms-max-item-count'] = self._serialize.header("x_ms_max_item_count", x_ms_max_item_count, 'int') + if x_ms_continuation is not None: + header_parameters['x-ms-continuation'] = self._serialize.header("x_ms_continuation", x_ms_continuation, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response) + + deserialized = None + header_dict = {} + + if response.status_code == 200: + deserialized = self._deserialize('[DeviceRegistrationState]', response) + header_dict = { + 'x-ms-continuation': 'str', + 'x-ms-max-item-count': 'int', + 'x-ms-item-type': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + query_device_registration_states.metadata = {'url': '/registrations/{id}/query'} diff --git a/azext_iot/sdk/dps/version.py b/azext_iot/sdk/dps/service/version.py similarity index 63% rename from azext_iot/sdk/dps/version.py rename to azext_iot/sdk/dps/service/version.py index e6c13ab40..a2a4832f8 100644 --- a/azext_iot/sdk/dps/version.py +++ b/azext_iot/sdk/dps/service/version.py @@ -1,9 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -VERSION = "2018-09-01-preview" +VERSION = "2019-03-31" diff --git a/azext_iot/tests/test_iot_dps_int.py b/azext_iot/tests/test_iot_dps_int.py index b3eb92174..41cca7d11 100644 --- a/azext_iot/tests/test_iot_dps_int.py +++ b/azext_iot/tests/test_iot_dps_int.py @@ -8,333 +8,547 @@ from azure.cli.testsdk import LiveScenarioTest from azext_iot.common.shared import EntityStatusType, AttestationType, AllocationType from azext_iot.common.certops import create_self_signed_certificate +from azext_iot.common import embedded_cli +from azext_iot.iothub.providers.discovery import IotHubDiscovery +from .settings import Setting # Set these to the proper IoT Hub DPS, IoT Hub and Resource Group for Integration Tests. -dps = os.environ.get('azext_iot_testdps') -rg = os.environ.get('azext_iot_testrg') -hub = os.environ.get('azext_iot_testhub') +dps = os.environ.get("azext_iot_testdps") +rg = os.environ.get("azext_iot_testrg") +hub = os.environ.get("azext_iot_testhub") if not all([dps, rg, hub]): - raise ValueError('Set azext_iot_testhub, azext_iot_testdps ' - 'and azext_iot_testrg to run integration tests.') - -cert_name = 'test' -cert_path = cert_name + '-cert.pem' -test_endorsement_key = ('AToAAQALAAMAsgAgg3GXZ0SEs/gakMyNRqXXJP1S124GUgtk8qHaGzMUaaoABgCAAEMAEAgAAAAAAAEAibym9HQP9vxCGF5dVc1Q' - 'QsAGe021aUGJzNol1/gycBx3jFsTpwmWbISRwnFvflWd0w2Mc44FAAZNaJOAAxwZvG8GvyLlHh6fGKdh+mSBL4iLH2bZ4Ry22cB3' - 'CJVjXmdGoz9Y/j3/NwLndBxQC+baNvzvyVQZ4/A2YL7vzIIj2ik4y+ve9ir7U0GbNdnxskqK1KFIITVVtkTIYyyFTIR0BySjPrRI' - 'Dj7r7Mh5uF9HBppGKQCBoVSVV8dI91lNazmSdpGWyqCkO7iM4VvUMv2HT/ym53aYlUrau+Qq87Tu+uQipWYgRdF11KDfcpMHqqzB' - 'QQ1NpOJVhrsTrhyJzO7KNw==') - - -class IoTDpsTest(LiveScenarioTest): + raise ValueError( + "Set azext_iot_testhub, azext_iot_testdps " + "and azext_iot_testrg to run integration tests." + ) + +cert_name = "test" +cert_path = cert_name + "-cert.pem" +test_endorsement_key = ( + "AToAAQALAAMAsgAgg3GXZ0SEs/gakMyNRqXXJP1S124GUgtk8qHaGzMUaaoABgCAAEMAEAgAAAAAAAEAibym9HQP9vxCGF5dVc1Q" + "QsAGe021aUGJzNol1/gycBx3jFsTpwmWbISRwnFvflWd0w2Mc44FAAZNaJOAAxwZvG8GvyLlHh6fGKdh+mSBL4iLH2bZ4Ry22cB3" + "CJVjXmdGoz9Y/j3/NwLndBxQC+baNvzvyVQZ4/A2YL7vzIIj2ik4y+ve9ir7U0GbNdnxskqK1KFIITVVtkTIYyyFTIR0BySjPrRI" + "Dj7r7Mh5uF9HBppGKQCBoVSVV8dI91lNazmSdpGWyqCkO7iM4VvUMv2HT/ym53aYlUrau+Qq87Tu+uQipWYgRdF11KDfcpMHqqzB" + "QQ1NpOJVhrsTrhyJzO7KNw==" +) +provisioning_status = EntityStatusType.enabled.value +provisioning_status_new = EntityStatusType.disabled.value + + +def _cleanup_enrollments(self, dps, rg): + enrollments = self.cmd( + "iot dps enrollment list --dps-name {} -g {}".format(dps, rg) + ).get_output_in_json() + if len(enrollments) > 0: + enrollment_ids = list(map(lambda x: x["registrationId"], enrollments)) + for id in enrollment_ids: + self.cmd( + "iot dps enrollment delete --dps-name {} -g {} --enrollment-id {}".format( + dps, rg, id + ) + ) + + enrollment_groups = self.cmd( + "iot dps enrollment-group list --dps-name {} -g {}".format(dps, rg) + ).get_output_in_json() + if len(enrollment_groups) > 0: + enrollment_ids = list(map(lambda x: x["enrollmentGroupId"], enrollment_groups)) + for id in enrollment_ids: + self.cmd( + "iot dps enrollment-group delete --dps-name {} -g {} --enrollment-id {}".format( + dps, rg, id + ) + ) + + self.cmd( + "iot dps enrollment list --dps-name {} -g {}".format(dps, rg), + checks=self.is_empty(), + ) + self.cmd( + "iot dps enrollment-group list --dps-name {} -g {}".format(dps, rg), + checks=self.is_empty(), + ) + + +def _ensure_dps_hub_link(self, dps, rg, hub): + cli = embedded_cli.EmbeddedCLI() + hubs = cli.invoke( + "iot dps linked-hub list --dps-name {} -g {}".format(dps, rg) + ).as_json() + if not len(hubs) or not len( + list( + filter( + lambda linked_hub: linked_hub["name"] + == "{}.azure-devices.net".format(hub), + hubs, + ) + ) + ): + discovery = IotHubDiscovery(self.cmd_shell) + target_hub = discovery.get_target(hub, rg) + cli.invoke( + "iot dps linked-hub create --dps-name {} -g {} --connection-string {} --location {}".format( + dps, rg, target_hub.get("cs"), target_hub.get("location") + ) + ) + + +class TestDPSEnrollments(LiveScenarioTest): + def __init__(self, test_method): + super(TestDPSEnrollments, self).__init__(test_method) + self.cmd_shell = Setting() + setattr(self.cmd_shell, "cli_ctx", self.cli_ctx) - provisioning_status = EntityStatusType.enabled.value - provisioning_status_new = EntityStatusType.disabled.value + _ensure_dps_hub_link(self, dps, rg, hub) - def __init__(self, test_method): - super(IoTDpsTest, self).__init__(test_method) output_dir = os.getcwd() create_self_signed_certificate(cert_name, 200, output_dir, True) - self.kwargs['generic_dict'] = {'count': None, 'key': 'value', 'metadata': None, 'version': None} + self.kwargs["generic_dict"] = { + "count": None, + "key": "value", + "metadata": None, + "version": None, + } + + _cleanup_enrollments(self, dps, rg) def __del__(self): if os.path.exists(cert_path): os.remove(cert_path) def test_dps_compute_device_key(self): - device_key = self.cmd('az iot dps compute-device-key --key "{}" ' - '--registration-id myarbitrarydeviceId'.format(test_endorsement_key)).output + device_key = self.cmd( + 'az iot dps compute-device-key --key "{}" ' + "--registration-id myarbitrarydeviceId".format(test_endorsement_key) + ).output device_key = device_key.strip("\"'\n") assert device_key == "cT/EXZvsplPEpT//p98Pc6sKh8mY3kYgSxavHwMkl7w=" def test_dps_enrollment_tpm_lifecycle(self): - enrollment_id = self.create_random_name('enrollment-for-test', length=48) - endorsement_key = test_endorsement_key - device_id = self.create_random_name('device-id-for-test', length=48) + enrollment_id = self.create_random_name("enrollment-for-test", length=48) + device_id = self.create_random_name("device-id-for-test", length=48) attestation_type = AttestationType.tpm.value - hub_host_name = '{}.azure-devices.net'.format(hub) - - etag = self.cmd('iot dps enrollment create --enrollment-id {} --attestation-type {}' - ' -g {} --dps-name {} --endorsement-key {}' - ' --provisioning-status {} --device-id {} --initial-twin-tags {}' - ' --initial-twin-properties {} --allocation-policy {} --iot-hubs {}' - .format(enrollment_id, attestation_type, rg, dps, endorsement_key, - self.provisioning_status, device_id, - '"{generic_dict}"', '"{generic_dict}"', AllocationType.static.value, hub_host_name), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status), - self.check('deviceId', device_id), - self.check('allocationPolicy', AllocationType.static.value), - self.check('iotHubs', hub_host_name.split()), - self.check('initialTwin.tags', - self.kwargs['generic_dict']), - self.check('initialTwin.properties.desired', - self.kwargs['generic_dict']), - self.exists('reprovisionPolicy'), - self.check('reprovisionPolicy.migrateDeviceData', True), - self.check('reprovisionPolicy.updateHubAssignment', True) - ]).get_output_in_json()['etag'] - - self.cmd('iot dps enrollment list -g {} --dps-name {}'.format(rg, dps), checks=[ - self.check('length(@)', 1), - self.check('[0].registrationId', enrollment_id) - ]) - - self.cmd('iot dps enrollment show -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id), - checks=[self.check('registrationId', enrollment_id)]) - - self.cmd('iot dps enrollment update -g {} --dps-name {} --enrollment-id {}' - ' --provisioning-status {} --etag {}' - .format(rg, dps, enrollment_id, self.provisioning_status_new, etag), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status_new), - self.check('deviceId', device_id), - self.check('allocationPolicy', AllocationType.static.value), - self.check('iotHubs', hub_host_name.split()), - self.exists('initialTwin.tags'), - self.exists('initialTwin.properties.desired') - ]) - - self.cmd('iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id)) + hub_host_name = "{}.azure-devices.net".format(hub) + + enrollment = self.cmd( + "iot dps enrollment create --enrollment-id {} --attestation-type {}" + " -g {} --dps-name {} --endorsement-key {}" + " --provisioning-status {} --device-id {} --initial-twin-tags {}" + " --initial-twin-properties {} --allocation-policy {} --iot-hubs {}".format( + enrollment_id, + attestation_type, + rg, + dps, + test_endorsement_key, + provisioning_status, + device_id, + '"{generic_dict}"', + '"{generic_dict}"', + AllocationType.static.value, + hub_host_name, + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id), + self.check("provisioningStatus", provisioning_status), + self.check("deviceId", device_id), + self.check("allocationPolicy", AllocationType.static.value), + self.check("iotHubs", hub_host_name.split()), + self.check("initialTwin.tags", self.kwargs["generic_dict"]), + self.check( + "initialTwin.properties.desired", self.kwargs["generic_dict"] + ), + self.exists("reprovisionPolicy"), + self.check("reprovisionPolicy.migrateDeviceData", True), + self.check("reprovisionPolicy.updateHubAssignment", True), + ], + ).get_output_in_json() + etag = enrollment["etag"] + + self.cmd( + "iot dps enrollment list -g {} --dps-name {}".format(rg, dps), + checks=[ + self.check("length(@)", 1), + self.check("[0].registrationId", enrollment_id), + ], + ) + + self.cmd( + "iot dps enrollment show -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ), + checks=[self.check("registrationId", enrollment_id)], + ) + + self.cmd( + "iot dps enrollment show -g {} --dps-name {} --enrollment-id {} --show-keys".format( + rg, dps, enrollment_id + ), + checks=[ + self.check("registrationId", enrollment_id), + self.check("attestation.type", attestation_type), + self.exists("attestation.{}".format(attestation_type)), + ], + ) + + self.cmd( + "iot dps enrollment update -g {} --dps-name {} --enrollment-id {}" + " --provisioning-status {} --etag {}".format( + rg, dps, enrollment_id, provisioning_status_new, etag + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id), + self.check("provisioningStatus", provisioning_status_new), + self.check("deviceId", device_id), + self.check("allocationPolicy", AllocationType.static.value), + self.check("iotHubs", hub_host_name.split()), + self.exists("initialTwin.tags"), + self.exists("initialTwin.properties.desired"), + ], + ) + + self.cmd( + "iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ) + ) def test_dps_enrollment_x509_lifecycle(self): - enrollment_id = self.create_random_name('enrollment-for-test', length=48) + enrollment_id = self.create_random_name("enrollment-for-test", length=48) attestation_type = AttestationType.x509.value - device_id = self.create_random_name('device-id-for-test', length=48) - hub_host_name = '{}.azure-devices.net'.format(hub) - - etag = self.cmd('iot dps enrollment create --enrollment-id {} --attestation-type {}' - ' -g {} --dps-name {} --cp {} --scp {}' - ' --provisioning-status {} --device-id {}' - ' --initial-twin-tags {} --initial-twin-properties {}' - ' --allocation-policy {} --iot-hubs {}' - .format(enrollment_id, attestation_type, rg, dps, cert_path, - cert_path, self.provisioning_status, device_id, - '"{generic_dict}"', '"{generic_dict}"', - AllocationType.hashed.value, - hub_host_name), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status), - self.check('deviceId', device_id), - self.check('allocationPolicy', AllocationType.hashed.value), - self.check('iotHubs', hub_host_name.split()), - self.check('initialTwin.tags', - self.kwargs['generic_dict']), - self.check('initialTwin.properties.desired', - self.kwargs['generic_dict']), - self.exists('reprovisionPolicy'), - self.check('reprovisionPolicy.migrateDeviceData', True), - self.check('reprovisionPolicy.updateHubAssignment', True) - ]).get_output_in_json()['etag'] - - self.cmd('iot dps enrollment list -g {} --dps-name {}'.format(rg, dps), - checks=[ - self.check('length(@)', 1), - self.check('[0].registrationId', enrollment_id)]) - - self.cmd('iot dps enrollment show -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id), - checks=[self.check('registrationId', enrollment_id)]) - - self.cmd('iot dps enrollment update -g {} --dps-name {} --enrollment-id {}' - ' --provisioning-status {} --etag {} --rc' - .format(rg, dps, enrollment_id, self.provisioning_status_new, etag), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status_new), - self.check('deviceId', device_id), - self.check('allocationPolicy', AllocationType.hashed.value), - self.check('iotHubs', hub_host_name.split()), - self.exists('initialTwin.tags'), - self.exists('initialTwin.properties.desired'), - self.check( - 'attestation.type.x509.clientCertificates.primary', None) - ]) - - self.cmd('iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id)) + device_id = self.create_random_name("device-id-for-test", length=48) + hub_host_name = "{}.azure-devices.net".format(hub) + + etag = self.cmd( + "iot dps enrollment create --enrollment-id {} --attestation-type {}" + " -g {} --dps-name {} --cp {} --scp {}" + " --provisioning-status {} --device-id {}" + " --initial-twin-tags {} --initial-twin-properties {}" + " --allocation-policy {} --iot-hubs {}".format( + enrollment_id, + attestation_type, + rg, + dps, + cert_path, + cert_path, + provisioning_status, + device_id, + '"{generic_dict}"', + '"{generic_dict}"', + AllocationType.hashed.value, + hub_host_name, + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id), + self.check("provisioningStatus", provisioning_status), + self.check("deviceId", device_id), + self.check("allocationPolicy", AllocationType.hashed.value), + self.check("iotHubs", hub_host_name.split()), + self.check("initialTwin.tags", self.kwargs["generic_dict"]), + self.check( + "initialTwin.properties.desired", self.kwargs["generic_dict"] + ), + self.exists("reprovisionPolicy"), + self.check("reprovisionPolicy.migrateDeviceData", True), + self.check("reprovisionPolicy.updateHubAssignment", True), + ], + ).get_output_in_json()["etag"] + + self.cmd( + "iot dps enrollment list -g {} --dps-name {}".format(rg, dps), + checks=[ + self.check("length(@)", 1), + self.check("[0].registrationId", enrollment_id), + ], + ) + + self.cmd( + "iot dps enrollment show -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ), + checks=[self.check("registrationId", enrollment_id)], + ) + + self.cmd( + "iot dps enrollment update -g {} --dps-name {} --enrollment-id {}" + " --provisioning-status {} --etag {} --rc".format( + rg, dps, enrollment_id, provisioning_status_new, etag + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id), + self.check("provisioningStatus", provisioning_status_new), + self.check("deviceId", device_id), + self.check("allocationPolicy", AllocationType.hashed.value), + self.check("iotHubs", hub_host_name.split()), + self.exists("initialTwin.tags"), + self.exists("initialTwin.properties.desired"), + self.check("attestation.type.x509.clientCertificates.primary", None), + ], + ) + + self.cmd( + "iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ) + ) def test_dps_enrollment_symmetrickey_lifecycle(self): - enrollment_id = self.create_random_name('enrollment-for-test', length=48) - enrollment_id2 = self.create_random_name('enrollment-for-test', length=48) + enrollment_id = self.create_random_name("enrollment-for-test", length=48) + enrollment_id2 = self.create_random_name("enrollment-for-test", length=48) attestation_type = AttestationType.symmetricKey.value - primary_key = 'x3XNu1HeSw93rmtDXduRUZjhqdGbcqR/zloWYiyPUzw=' - secondary_key = 'PahMnOSBblv9CRn5B765iK35jTvnjDUjYP9hKBZa4Ug=' - device_id = self.create_random_name('device-id-for-test', length=48) - reprovisionPolicy_reprovisionandresetdata = 'reprovisionandresetdata' - hub_host_name = '{}.azure-devices.net'.format(hub) - webhook_url = 'https://www.test.test' - api_version = '2019-03-31' - - etag = self.cmd('iot dps enrollment create --enrollment-id {} --attestation-type {}' - ' -g {} --dps-name {} --pk {} --sk {}' - ' --provisioning-status {} --device-id {}' - ' --initial-twin-tags {} --initial-twin-properties {}' - ' --allocation-policy {} --rp {} --iot-hubs {} --edge-enabled' - .format(enrollment_id, attestation_type, rg, dps, primary_key, - secondary_key, self.provisioning_status, device_id, - '"{generic_dict}"', '"{generic_dict}"', - AllocationType.geolatency.value, - reprovisionPolicy_reprovisionandresetdata, - hub_host_name), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status), - self.check('deviceId', device_id), - self.check('allocationPolicy', 'geoLatency'), - self.check('iotHubs', hub_host_name.split()), - self.check('initialTwin.tags', - self.kwargs['generic_dict']), - self.check('initialTwin.properties.desired', - self.kwargs['generic_dict']), - self.exists('reprovisionPolicy'), - self.check('reprovisionPolicy.migrateDeviceData', False), - self.check('reprovisionPolicy.updateHubAssignment', True), - self.check('capabilities.iotEdge', True) - ]).get_output_in_json()['etag'] - - self.cmd('iot dps enrollment list -g {} --dps-name {}'.format(rg, dps), - checks=[ - self.check('length(@)', 1), - self.check('[0].registrationId', enrollment_id)]) - - self.cmd('iot dps enrollment show -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id), - checks=[self.check('registrationId', enrollment_id)]) - - self.cmd('iot dps enrollment update -g {} --dps-name {} --enrollment-id {}' - ' --provisioning-status {} --etag {} --edge-enabled False' - ' --allocation-policy {} --webhook-url {} --api-version {}' - .format(rg, dps, enrollment_id, self.provisioning_status_new, etag, - AllocationType.custom.value, webhook_url, api_version), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status_new), - self.check('deviceId', device_id), - self.check('allocationPolicy', "custom"), - self.check('customAllocationDefinition.webhookUrl', webhook_url), - self.check('customAllocationDefinition.apiVersion', api_version), - # self.check('iotHubs', hub_host_name.split()), TODO - self.exists('initialTwin.tags'), - self.exists('initialTwin.properties.desired'), - self.check('attestation.symmetricKey.primaryKey', primary_key), - self.check('capabilities.iotEdge', False) - ]) - - self.cmd('iot dps enrollment create --enrollment-id {} --attestation-type {}' - ' -g {} --dps-name {} --allocation-policy {} --webhook-url {} --api-version {}' - .format(enrollment_id2, attestation_type, rg, dps, AllocationType.custom.value, - webhook_url, api_version), - checks=[ - self.check('attestation.type', attestation_type), - self.check('registrationId', enrollment_id2), - self.check('allocationPolicy', 'custom'), - self.check('customAllocationDefinition.webhookUrl', webhook_url), - self.check('customAllocationDefinition.apiVersion', api_version), - ]) - - self.cmd('iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id)) - self.cmd('iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id2)) + primary_key = "x3XNu1HeSw93rmtDXduRUZjhqdGbcqR/zloWYiyPUzw=" + secondary_key = "PahMnOSBblv9CRn5B765iK35jTvnjDUjYP9hKBZa4Ug=" + device_id = self.create_random_name("device-id-for-test", length=48) + reprovisionPolicy_reprovisionandresetdata = "reprovisionandresetdata" + hub_host_name = "{}.azure-devices.net".format(hub) + webhook_url = "https://www.test.test" + api_version = "2019-03-31" + + etag = self.cmd( + "iot dps enrollment create --enrollment-id {} --attestation-type {}" + " -g {} --dps-name {} --pk {} --sk {}" + " --provisioning-status {} --device-id {}" + " --initial-twin-tags {} --initial-twin-properties {}" + " --allocation-policy {} --rp {} --iot-hubs {} --edge-enabled".format( + enrollment_id, + attestation_type, + rg, + dps, + primary_key, + secondary_key, + provisioning_status, + device_id, + '"{generic_dict}"', + '"{generic_dict}"', + AllocationType.geolatency.value, + reprovisionPolicy_reprovisionandresetdata, + hub_host_name, + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id), + self.check("provisioningStatus", provisioning_status), + self.check("deviceId", device_id), + self.check("allocationPolicy", "geoLatency"), + # self.check("iotHubs", hub_host_name.split()), + self.check("initialTwin.tags", self.kwargs["generic_dict"]), + self.check( + "initialTwin.properties.desired", self.kwargs["generic_dict"] + ), + self.exists("reprovisionPolicy"), + self.check("reprovisionPolicy.migrateDeviceData", False), + self.check("reprovisionPolicy.updateHubAssignment", True), + self.check("capabilities.iotEdge", True), + ], + ).get_output_in_json()["etag"] + + self.cmd( + "iot dps enrollment list -g {} --dps-name {}".format(rg, dps), + checks=[ + self.check("length(@)", 1), + self.check("[0].registrationId", enrollment_id), + ], + ) + + self.cmd( + "iot dps enrollment show -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ), + checks=[self.check("registrationId", enrollment_id)], + ) + + self.cmd( + "iot dps enrollment update -g {} --dps-name {} --enrollment-id {}" + " --provisioning-status {} --etag {} --edge-enabled False" + " --allocation-policy {} --webhook-url {} --api-version {}".format( + rg, + dps, + enrollment_id, + provisioning_status_new, + etag, + AllocationType.custom.value, + webhook_url, + api_version, + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id), + self.check("provisioningStatus", provisioning_status_new), + self.check("deviceId", device_id), + self.check("allocationPolicy", "custom"), + self.check("customAllocationDefinition.webhookUrl", webhook_url), + self.check("customAllocationDefinition.apiVersion", api_version), + # self.check("iotHubs", hub_host_name.split()), + self.exists("initialTwin.tags"), + self.exists("initialTwin.properties.desired"), + self.check("attestation.symmetricKey.primaryKey", primary_key), + self.check("capabilities.iotEdge", False), + ], + ) + + self.cmd( + "iot dps enrollment create --enrollment-id {} --attestation-type {}" + " -g {} --dps-name {} --allocation-policy {} --webhook-url {} --api-version {}".format( + enrollment_id2, + attestation_type, + rg, + dps, + AllocationType.custom.value, + webhook_url, + api_version, + ), + checks=[ + self.check("attestation.type", attestation_type), + self.check("registrationId", enrollment_id2), + self.check("allocationPolicy", "custom"), + self.check("customAllocationDefinition.webhookUrl", webhook_url), + self.check("customAllocationDefinition.apiVersion", api_version), + ], + ) + + self.cmd( + "iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ) + ) + self.cmd( + "iot dps enrollment delete -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id2 + ) + ) def test_dps_enrollment_group_lifecycle(self): - enrollment_id = self.create_random_name('enrollment-for-test', length=48) - reprovisionPolicy_never = 'never' - hub_host_name = '{}.azure-devices.net'.format(hub) - webhook_url = 'https://www.test.test' - api_version = '2019-03-31' - etag = self.cmd('iot dps enrollment-group create --enrollment-id {} -g {} --dps-name {}' - ' --cp {} --scp {} --provisioning-status {} --allocation-policy {}' - ' --iot-hubs {} --edge-enabled' - .format(enrollment_id, rg, dps, cert_path, cert_path, - self.provisioning_status, "geoLatency", - hub_host_name), - checks=[ - self.check('enrollmentGroupId', enrollment_id), - self.check('provisioningStatus', - self.provisioning_status), - self.exists('reprovisionPolicy'), - self.check('allocationPolicy', "geoLatency"), - self.check('iotHubs', hub_host_name.split()), - self.check('reprovisionPolicy.migrateDeviceData', True), - self.check('reprovisionPolicy.updateHubAssignment', True), - self.check('capabilities.iotEdge', True) - ]).get_output_in_json()['etag'] - - self.cmd('iot dps enrollment-group list -g {} --dps-name {}'.format(rg, dps), checks=[ - self.check('length(@)', 1), - self.check('[0].enrollmentGroupId', enrollment_id) - ]) - - self.cmd('iot dps enrollment-group show -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id), - checks=[self.check('enrollmentGroupId', enrollment_id)]) - - etag = self.cmd('iot dps enrollment-group update -g {} --dps-name {} --enrollment-id {}' - ' --provisioning-status {} --rsc --etag {} --rp {} --allocation-policy {}' - ' --edge-enabled False --scp {}' - .format(rg, dps, enrollment_id, self.provisioning_status_new, etag, - reprovisionPolicy_never, AllocationType.hashed.value, - cert_path), - checks=[ - self.check('attestation.type', AttestationType.x509.value), - self.check('enrollmentGroupId', enrollment_id), - self.check('provisioningStatus', self.provisioning_status_new), - self.check('attestation.type.x509.clientCertificates.secondary', None), - self.exists('reprovisionPolicy'), - self.check('allocationPolicy', AllocationType.hashed.value), - self.check('reprovisionPolicy.migrateDeviceData', False), - self.check('reprovisionPolicy.updateHubAssignment', False), - self.check('capabilities.iotEdge', False) - ]).get_output_in_json()['etag'] - - self.cmd('iot dps registration list -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id), - checks=[self.check('length(@)', 0)]) - - cert_name = self.create_random_name('certificate-for-test', length=48) - cert_etag = self.cmd('iot dps certificate create -g {} --dps-name {} --name {} --p {}' - .format(rg, dps, cert_name, cert_path), - checks=[self.check('name', cert_name)]).get_output_in_json()['etag'] - - self.cmd('iot dps enrollment-group update -g {} --dps-name {} --enrollment-id {}' - ' --cn {} --etag {} --allocation-policy {} --webhook-url {} --api-version {}' - .format(rg, dps, enrollment_id, cert_name, etag, - AllocationType.custom.value, webhook_url, api_version), - checks=[ - self.check('attestation.type', - AttestationType.x509.value), - self.check('enrollmentGroupId', enrollment_id), - self.check('allocationPolicy', "custom"), - self.check('customAllocationDefinition.webhookUrl', webhook_url), - self.check('customAllocationDefinition.apiVersion', api_version), - self.check( - 'attestation.x509.caReferences.primary', cert_name), - self.check( - 'attestation.x509.caReferences.secondary', None) - ]) - - self.cmd('iot dps enrollment-group delete -g {} --dps-name {} --enrollment-id {}' - .format(rg, dps, enrollment_id)) - - self.cmd('iot dps certificate delete -g {} --dps-name {} --name {} --etag {}' - .format(rg, dps, cert_name, cert_etag)) + enrollment_id = self.create_random_name("enrollment-for-test", length=48) + reprovisionPolicy_never = "never" + hub_host_name = "{}.azure-devices.net".format(hub) + webhook_url = "https://www.test.test" + api_version = "2019-03-31" + etag = self.cmd( + "iot dps enrollment-group create --enrollment-id {} -g {} --dps-name {}" + " --cp {} --scp {} --provisioning-status {} --allocation-policy {}" + " --iot-hubs {} --edge-enabled".format( + enrollment_id, + rg, + dps, + cert_path, + cert_path, + provisioning_status, + "geoLatency", + hub_host_name, + ), + checks=[ + self.check("enrollmentGroupId", enrollment_id), + self.check("provisioningStatus", provisioning_status), + self.exists("reprovisionPolicy"), + self.check("allocationPolicy", "geoLatency"), + self.check("iotHubs", hub_host_name.split()), + self.check("reprovisionPolicy.migrateDeviceData", True), + self.check("reprovisionPolicy.updateHubAssignment", True), + self.check("capabilities.iotEdge", True), + ], + ).get_output_in_json()["etag"] + + self.cmd( + "iot dps enrollment-group list -g {} --dps-name {}".format(rg, dps), + checks=[ + self.check("length(@)", 1), + self.check("[0].enrollmentGroupId", enrollment_id), + ], + ) + + self.cmd( + "iot dps enrollment-group show -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ), + checks=[self.check("enrollmentGroupId", enrollment_id)], + ) + + self.cmd( + "iot dps enrollment-group show -g {} --dps-name {} --enrollment-id {} --show-keys".format( + rg, dps, enrollment_id + ), + checks=[ + self.check("enrollmentGroupId", enrollment_id), + self.exists("attestation.x509"), + ], + ) + + etag = self.cmd( + "iot dps enrollment-group update -g {} --dps-name {} --enrollment-id {}" + " --provisioning-status {} --rsc --etag {} --rp {} --allocation-policy {}" + " --edge-enabled False --scp {}".format( + rg, + dps, + enrollment_id, + provisioning_status_new, + etag, + reprovisionPolicy_never, + AllocationType.hashed.value, + cert_path, + ), + checks=[ + self.check("attestation.type", AttestationType.x509.value), + self.check("enrollmentGroupId", enrollment_id), + self.check("provisioningStatus", provisioning_status_new), + self.check("attestation.type.x509.clientCertificates.secondary", None), + self.exists("reprovisionPolicy"), + self.check("allocationPolicy", AllocationType.hashed.value), + self.check("reprovisionPolicy.migrateDeviceData", False), + self.check("reprovisionPolicy.updateHubAssignment", False), + self.check("capabilities.iotEdge", False), + ], + ).get_output_in_json()["etag"] + + self.cmd( + "iot dps registration list -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ), + checks=[self.check("length(@)", 0)], + ) + + cert_name = self.create_random_name("certificate-for-test", length=48) + cert_etag = self.cmd( + "iot dps certificate create -g {} --dps-name {} --name {} --p {}".format( + rg, dps, cert_name, cert_path + ), + checks=[self.check("name", cert_name)], + ).get_output_in_json()["etag"] + + self.cmd( + "iot dps enrollment-group update -g {} --dps-name {} --enrollment-id {}" + " --cn {} --etag {} --allocation-policy {} --webhook-url {} --api-version {}".format( + rg, + dps, + enrollment_id, + cert_name, + etag, + AllocationType.custom.value, + webhook_url, + api_version, + ), + checks=[ + self.check("attestation.type", AttestationType.x509.value), + self.check("enrollmentGroupId", enrollment_id), + self.check("allocationPolicy", "custom"), + self.check("customAllocationDefinition.webhookUrl", webhook_url), + self.check("customAllocationDefinition.apiVersion", api_version), + self.check("attestation.x509.caReferences.primary", cert_name), + self.check("attestation.x509.caReferences.secondary", None), + ], + ) + + self.cmd( + "iot dps enrollment-group delete -g {} --dps-name {} --enrollment-id {}".format( + rg, dps, enrollment_id + ) + ) + + self.cmd( + "iot dps certificate delete -g {} --dps-name {} --name {} --etag {}".format( + rg, dps, cert_name, cert_etag + ) + ) diff --git a/azext_iot/tests/test_iot_dps_unit.py b/azext_iot/tests/test_iot_dps_unit.py index 8476df211..bfe308921 100644 --- a/azext_iot/tests/test_iot_dps_unit.py +++ b/azext_iot/tests/test_iot_dps_unit.py @@ -13,10 +13,10 @@ import pytest import json +import responses from azext_iot.operations import dps as subject from knack.util import CLIError from azext_iot.common.sas_token_auth import SasTokenAuthentication -from .conftest import build_mock_response enrollment_id = 'myenrollment' resource_group = 'myrg' @@ -31,6 +31,13 @@ mock_target['policy'] = 'provisioningserviceowner' mock_target['subscription'] = "5952cff8-bcd1-4235-9554-af2c0348bf23" +mock_symmetric_key_attestation = { + "type": "symmetricKey", + "symmetricKey": { + "primaryKey": "primary_key", + "secondaryKey": "secondary_key" + }, +} # Patch Paths # path_service_client = 'msrest.service_client.ServiceClient.send' @@ -40,8 +47,8 @@ @pytest.fixture() def fixture_gdcs(mocker): - ghcs = mocker.patch(path_gdcs) - ghcs.return_value = mock_target + gdcs = mocker.patch(path_gdcs) + gdcs.return_value = mock_target @pytest.fixture() @@ -53,13 +60,6 @@ def fixture_sas(mocker): sas.return_value = r -@pytest.fixture(params=[400, 401, 500]) -def serviceclient_generic_error(mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, {'error': 'something failed'}) - return service_client - - def generate_enrollment_create_req(attestation_type=None, endorsement_key=None, certificate_path=None, secondary_certificate_path=None, device_Id=None, iot_hub_host_name=None, @@ -91,11 +91,29 @@ def generate_enrollment_create_req(attestation_type=None, endorsement_key=None, class TestEnrollmentCreate(): - @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, {}) - return service_client + @pytest.fixture() + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas): + mocked_response.add( + method=responses.PUT, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body='{}', + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response + + @pytest.fixture(params=[400, 401, 500]) + def serviceclient_generic_error(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.PUT, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body='{}', + status=request.param, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response @pytest.mark.parametrize("req", [ (generate_enrollment_create_req(attestation_type='tpm', @@ -165,8 +183,8 @@ def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): secondary_key='secondarykey', edge_enabled=True)), ]) - def test_enrollment_create(self, serviceclient, req): - subject.iot_dps_device_enrollment_create(None, + def test_enrollment_create(self, serviceclient, fixture_cmd, req): + subject.iot_dps_device_enrollment_create(fixture_cmd, req['enrollment_id'], req['attestation_type'], req['dps_name'], req['rg'], @@ -186,12 +204,12 @@ def test_enrollment_create(self, serviceclient, req): req['edge_enabled'], req['webhook_url'], req['api_version']) - args = serviceclient.call_args - url = args[0][0].url + request = serviceclient.calls[0].request + url = request.url assert "{}/enrollments/{}?".format(mock_target['entity'], enrollment_id) in url - assert args[0][0].method == 'PUT' + assert request.method == 'PUT' - body = args[0][2] + body = json.loads(request.body) assert body['registrationId'] == req['enrollment_id'] if req['attestation_type'] == 'tpm': assert body['attestation']['type'] == req['attestation_type'] @@ -258,9 +276,9 @@ def test_enrollment_create(self, serviceclient, req): (generate_enrollment_create_req(allocation_policy='static', iot_hub_host_name='hubname')), (generate_enrollment_create_req(iot_hubs='hub1 hub2')) ]) - def test_enrollment_create_invalid_args(self, serviceclient, req): + def test_enrollment_create_invalid_args(self, fixture_gdcs, fixture_cmd, req): with pytest.raises(CLIError): - subject.iot_dps_device_enrollment_create(None, req['enrollment_id'], + subject.iot_dps_device_enrollment_create(fixture_cmd, req['enrollment_id'], req['attestation_type'], req['dps_name'], req['rg'], req['endorsement_key'], @@ -349,15 +367,28 @@ def generate_enrollment_update_req(certificate_path=None, iot_hub_host_name=None class TestEnrollmentUpdate(): - @pytest.fixture(params=[(200, generate_enrollment_show(), 200)]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - test_side_effect = [ - build_mock_response(mocker, request.param[0], request.param[1]), - build_mock_response(mocker, request.param[2]) - ] - service_client.side_effect = test_side_effect - return service_client + @pytest.fixture() + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + # Initial GET + mocked_response.add( + method=responses.GET, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_show()), + status=200, + content_type="application/json", + match_querystring=False, + ) + + # Update PUT + mocked_response.add( + method=responses.PUT, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_show()), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response @pytest.mark.parametrize("req", [ (generate_enrollment_update_req(etag=etag, secondary_certificate_path='someOtherCertPath')), @@ -404,14 +435,17 @@ def test_enrollment_update(self, serviceclient, req): req['edge_enabled'], req['webhook_url'], req['api_version']) - # Index 1 is the update args - args = serviceclient.call_args_list[1] - url = args[0][0].url + get_request = serviceclient.calls[0].request + assert get_request.method == 'GET' + assert "{}/enrollments/{}?".format(mock_target['entity'], enrollment_id) in get_request.url + + update_request = serviceclient.calls[1].request + url = update_request.url assert "{}/enrollments/{}?".format(mock_target['entity'], enrollment_id) in url - assert args[0][0].method == 'PUT' + assert update_request.method == 'PUT' - body = args[0][2] + body = json.loads(update_request.body) if not req['certificate_path']: if req['remove_certificate_path']: assert body['attestation']['x509']['clientCertificates'].get('primary') is None @@ -454,22 +488,73 @@ def test_enrollment_update(self, serviceclient, req): class TestEnrollmentShow(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, generate_enrollment_show()) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.GET, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_show()), + status=request.param, + content_type="application/json", + match_querystring=False, + ) + + yield mocked_response + + @pytest.fixture() + def serviceclient_attestation(self, mocked_response, fixture_gdcs, fixture_sas): + mocked_response.add( + method=responses.GET, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_show(attestation=mock_symmetric_key_attestation)), + status=200, + content_type="application/json", + match_querystring=False, + ) + + mocked_response.add( + method=responses.POST, + url="https://{}/enrollments/{}/attestationmechanism".format(mock_target['entity'], enrollment_id), + body=json.dumps(mock_symmetric_key_attestation), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response def test_enrollment_show(self, serviceclient): result = subject.iot_dps_device_enrollment_get(None, enrollment_id, mock_target['entity'], resource_group) - assert result.registration_id == enrollment_id - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + assert result['registrationId'] == enrollment_id + + request = serviceclient.calls[0].request + url = request.url + method = request.method + + assert "{}/enrollments/{}?".format(mock_target['entity'], enrollment_id) in url + assert method == 'GET' + + def test_enrollment_show_with_keys(self, serviceclient_attestation): + result = subject.iot_dps_device_enrollment_get(None, enrollment_id, + mock_target['entity'], resource_group, show_keys=True) + + assert result['registrationId'] == enrollment_id + assert result['attestation'] + + request = serviceclient_attestation.calls[0].request + url = request.url + method = request.method + assert "{}/enrollments/{}?".format(mock_target['entity'], enrollment_id) in url assert method == 'GET' + request = serviceclient_attestation.calls[1].request + url = request.url + method = request.method + + assert "{}/enrollments/{}/attestationmechanism?".format(mock_target['entity'], enrollment_id) in url + assert method == 'POST' + def test_enrollment_show_error(self, serviceclient_generic_error): with pytest.raises(CLIError): subject.iot_dps_device_enrollment_get(None, enrollment_id, @@ -478,18 +563,24 @@ def test_enrollment_show_error(self, serviceclient_generic_error): class TestEnrollmentList(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, [generate_enrollment_show()]) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.POST, + url="https://{}/enrollments/query?".format(mock_target['entity']), + body=json.dumps([generate_enrollment_show()]), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response @pytest.mark.parametrize("top", [3, None]) def test_enrollment_list(self, serviceclient, top): result = subject.iot_dps_device_enrollment_list(None, mock_target['entity'], resource_group, top) - args = serviceclient.call_args_list[0] - headers = args[0][1] - url = args[0][0].url - method = args[0][0].method + request = serviceclient.calls[0].request + headers = request.headers + url = request.url + method = request.method assert str(headers.get("x-ms-max-item-count")) == str(top) assert "{}/enrollments/query?".format(mock_target['entity']) in url @@ -503,20 +594,23 @@ def test_enrollment_list_error(self, serviceclient_generic_error): class TestEnrollmentDelete(): @pytest.fixture(params=[204]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - response = mocker.MagicMock(name='response') - del response._attribute_map - response.status_code = request.param - service_client.return_value = response - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.DELETE, + url="https://{}/enrollments/{}".format(mock_target['entity'], enrollment_id), + body='{}', + status=request.param, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response def test_enrollment_delete(self, serviceclient): subject.iot_dps_device_enrollment_delete(None, enrollment_id, mock_target['entity'], resource_group) - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + request = serviceclient.calls[0].request + url = request.url + method = request.method assert "{}/enrollments/{}?".format(mock_target['entity'], enrollment_id) in url assert method == 'DELETE' @@ -566,10 +660,16 @@ def generate_enrollment_group_create_req(iot_hub_host_name=None, class TestEnrollmentGroupCreate(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, {}) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.PUT, + url="https://{}/enrollmentGroups/{}".format(mock_target['entity'], enrollment_id), + body='{}', + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response @pytest.mark.parametrize("req", [ (generate_enrollment_group_create_req(primary_key='primarykey', @@ -627,12 +727,12 @@ def test_enrollment_group_create(self, serviceclient, req): req['edge_enabled'], req['webhook_url'], req['api_version']) - args = serviceclient.call_args - url = args[0][0].url + request = serviceclient.calls[0].request + url = request.url assert "{}/enrollmentGroups/{}?".format(mock_target['entity'], enrollment_id) in url - assert args[0][0].method == 'PUT' + assert request.method == 'PUT' - body = args[0][2] + body = json.loads(request.body) assert body['enrollmentGroupId'] == req['enrollment_id'] if req['certificate_path']: assert body['attestation']['type'] == 'x509' @@ -700,7 +800,7 @@ def test_enrollment_group_create(self, serviceclient, req): (generate_enrollment_group_create_req(allocation_policy='static', iot_hubs='hub1 hub2')), (generate_enrollment_group_create_req(iot_hubs='hub1 hub2')) ]) - def test_enrollment_group_create_invalid_args(self, serviceclient, req): + def test_enrollment_group_create_invalid_args(self, req): with pytest.raises(CLIError): subject.iot_dps_device_enrollment_group_create(None, req['enrollment_id'], @@ -808,14 +908,26 @@ def generate_enrollment_group_update_req(iot_hub_host_name=None, class TestEnrollmentGroupUpdate(): @pytest.fixture(params=[(200, generate_enrollment_group_show(), 200)]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - test_side_effect = [ - build_mock_response(mocker, request.param[0], request.param[1]), - build_mock_response(mocker, request.param[2]) - ] - service_client.side_effect = test_side_effect - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + # Initial GET + mocked_response.add( + method=responses.GET, + url="https://{}/enrollmentGroups/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_group_show()), + status=200, + content_type="application/json", + match_querystring=False, + ) + # Update PUT + mocked_response.add( + method=responses.PUT, + url="https://{}/enrollmentGroups/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_group_show()), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response @pytest.mark.parametrize("req", [ (generate_enrollment_group_update_req(etag=etag, secondary_certificate_path='someOtherCertPath')), @@ -864,14 +976,19 @@ def test_enrollment_group_update(self, serviceclient, req): req['edge_enabled'], req['webhook_url'], req['api_version']) - # Index 1 is the update args - args = serviceclient.call_args_list[1] - url = args[0][0].url + # test initial GET + request = serviceclient.calls[0].request + url = request.url + assert "{}/enrollmentGroups/{}?".format(mock_target['entity'], enrollment_id) in url + assert request.method == 'GET' + + request = serviceclient.calls[1].request + url = request.url assert "{}/enrollmentGroups/{}?".format(mock_target['entity'], enrollment_id) in url - assert args[0][0].method == 'PUT' + assert request.method == 'PUT' - body = args[0][2] + body = json.loads(request.body) if not req['certificate_path']: if not req['root_ca_name'] and not req['secondary_root_ca_name']: assert body['attestation']['x509']['signingCertificates']['primary']['info'] is not None @@ -933,7 +1050,7 @@ def test_enrollment_group_update(self, serviceclient, req): (generate_enrollment_group_update_req(allocation_policy='static', iot_hubs='hub1 hub2')), (generate_enrollment_group_update_req(iot_hubs='hub1 hub2')) ]) - def test_enrollment_group_update_invalid_args(self, serviceclient, req): + def test_enrollment_group_update_invalid_args(self, req): with pytest.raises(CLIError): subject.iot_dps_device_enrollment_group_update(None, req['enrollment_id'], @@ -961,21 +1078,70 @@ def test_enrollment_group_update_invalid_args(self, serviceclient, req): class TestEnrollmentGroupShow(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, generate_enrollment_group_show()) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.GET, + url="https://{}/enrollmentGroups/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_group_show()), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response + + @pytest.fixture() + def serviceclient_attestation(self, mocked_response, fixture_gdcs, fixture_sas): + mocked_response.add( + method=responses.GET, + url="https://{}/enrollmentGroups/{}".format(mock_target['entity'], enrollment_id), + body=json.dumps(generate_enrollment_group_show(attestation=mock_symmetric_key_attestation)), + status=200, + content_type="application/json", + match_querystring=False, + ) + + mocked_response.add( + method=responses.POST, + url="https://{}/enrollmentGroups/{}/attestationmechanism".format(mock_target['entity'], enrollment_id), + body=json.dumps(mock_symmetric_key_attestation), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response def test_enrollment_group_show(self, serviceclient): result = subject.iot_dps_device_enrollment_group_get(None, enrollment_id, mock_target['entity'], resource_group) - assert result.enrollment_group_id == enrollment_id - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + assert result['enrollmentGroupId'] == enrollment_id + assert result['attestation'] + request = serviceclient.calls[0].request + url = request.url + method = request.method + + assert "{}/enrollmentGroups/{}?".format(mock_target['entity'], enrollment_id) in url + assert method == 'GET' + + def test_enrollment_group_show_with_keys(self, serviceclient_attestation): + result = subject.iot_dps_device_enrollment_group_get(None, enrollment_id, + mock_target['entity'], resource_group, show_keys=True) + assert result['enrollmentGroupId'] == enrollment_id + assert result['attestation'] + + request = serviceclient_attestation.calls[0].request + url = request.url + method = request.method + assert "{}/enrollmentGroups/{}?".format(mock_target['entity'], enrollment_id) in url assert method == 'GET' + request = serviceclient_attestation.calls[1].request + url = request.url + method = request.method + + assert "{}/enrollmentGroups/{}/attestationmechanism?".format(mock_target['entity'], enrollment_id) in url + assert method == 'POST' + def test_enrollment_group_show_error(self, serviceclient_generic_error): with pytest.raises(CLIError): subject.iot_dps_device_enrollment_group_get(None, enrollment_id, @@ -984,25 +1150,31 @@ def test_enrollment_group_show_error(self, serviceclient_generic_error): class TestEnrollmentGroupList(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, [generate_enrollment_group_show()]) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.POST, + url="https://{}/enrollmentGroups/query?".format(mock_target['entity']), + body=json.dumps([generate_enrollment_group_show()]), + status=200, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response @pytest.mark.parametrize("top", [5, None]) def test_enrollment_group_list(self, serviceclient, top): result = subject.iot_dps_device_enrollment_group_list(None, mock_target['entity'], resource_group, top) - args = serviceclient.call_args_list[0] - headers = args[0][1] - url = args[0][0].url - method = args[0][0].method + request = serviceclient.calls[0].request + headers = request.headers + url = request.url + method = request.method assert "{}/enrollmentGroups/query?".format(mock_target['entity']) in url assert method == 'POST' assert json.dumps(result) assert str(headers.get("x-ms-max-item-count")) == str(top) - def test_enrollment_group_list_error(self, serviceclient_generic_error): + def test_enrollment_group_list_error(self): with pytest.raises(CLIError): subject.iot_dps_device_enrollment_group_list(None, mock_target['entity'], @@ -1011,21 +1183,27 @@ def test_enrollment_group_list_error(self, serviceclient_generic_error): class TestEnrollmentGroupDelete(): @pytest.fixture(params=[204]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, {}) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.DELETE, + url="https://{}/enrollmentGroups/{}".format(mock_target['entity'], enrollment_id), + body='{}', + status=request.param, + content_type="application/json", + match_querystring=False, + ) + yield mocked_response def test_enrollment_group_delete(self, serviceclient): subject.iot_dps_device_enrollment_group_delete(None, enrollment_id, mock_target['entity'], resource_group) - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + request = serviceclient.calls[0].request + url = request.url + method = request.method assert "{}/enrollmentGroups/{}?".format(mock_target['entity'], enrollment_id) in url assert method == 'DELETE' - def test_enrollment_group_delete_error(self, serviceclient_generic_error): + def test_enrollment_group_delete_error(self): with pytest.raises(CLIError): subject.iot_dps_device_enrollment_group_delete(None, enrollment_id, mock_target['entity'], resource_group) @@ -1039,22 +1217,28 @@ def generate_registration_state_show(): class TestRegistrationShow(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, generate_registration_state_show()) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.GET, + url="https://{}/registrations/{}?".format(mock_target['entity'], registration_id), + body=json.dumps(generate_registration_state_show()), + status=request.param, + content_type="application/json", + match_querystring=False + ) + yield mocked_response def test_registration_show(self, serviceclient): result = subject.iot_dps_registration_get(None, mock_target['entity'], resource_group, registration_id) - assert result.registration_id == registration_id - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + assert result['registrationId'] == registration_id + request = serviceclient.calls[0].request + url = request.url + method = request.method assert "{}/registrations/{}?".format(mock_target['entity'], registration_id) in url assert method == 'GET' - def test_registration_show_error(self, serviceclient_generic_error): + def test_registration_show_error(self): with pytest.raises(CLIError): subject.iot_dps_registration_get(None, registration_id, mock_target['entity'], resource_group) @@ -1062,23 +1246,27 @@ def test_registration_show_error(self, serviceclient_generic_error): class TestRegistrationList(): @pytest.fixture(params=[200]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - result = [] - result.append(generate_registration_state_show()) - service_client.return_value = build_mock_response(mocker, request.param, result) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.POST, + url="https://{}/registrations/{}/query?".format(mock_target['entity'], enrollment_id), + body=json.dumps([generate_registration_state_show()]), + status=request.param, + content_type="application/json", + match_querystring=False + ) + yield mocked_response def test_registration_list(self, serviceclient): subject.iot_dps_registration_list(None, mock_target['entity'], resource_group, enrollment_id) - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + request = serviceclient.calls[0].request + url = request.url + method = request.method assert "{}/registrations/{}/query?".format(mock_target['entity'], enrollment_id) in url assert method == 'POST' - def test_registration_list_error(self, serviceclient_generic_error): + def test_registration_list_error(self): with pytest.raises(CLIError): subject.iot_dps_registration_list(None, mock_target['entity'], resource_group, enrollment_id) @@ -1086,21 +1274,27 @@ def test_registration_list_error(self, serviceclient_generic_error): class TestRegistrationDelete(): @pytest.fixture(params=[204]) - def serviceclient(self, mocker, fixture_gdcs, fixture_sas, request): - service_client = mocker.patch(path_service_client) - service_client.return_value = build_mock_response(mocker, request.param, {}) - return service_client + def serviceclient(self, mocked_response, fixture_gdcs, fixture_sas, request): + mocked_response.add( + method=responses.DELETE, + url="https://{}/registrations/{}".format(mock_target['entity'], registration_id), + body='{}', + status=request.param, + content_type="application/json", + match_querystring=False + ) + yield mocked_response def test_registration_delete(self, serviceclient): subject.iot_dps_registration_delete(None, mock_target['entity'], resource_group, registration_id) - args = serviceclient.call_args - url = args[0][0].url - method = args[0][0].method + request = serviceclient.calls[0].request + url = request.url + method = request.method assert "{}/registrations/{}?".format(mock_target['entity'], registration_id) in url assert method == 'DELETE' - def test_registration_delete_error(self, serviceclient_generic_error): + def test_registration_delete_error(self): with pytest.raises(CLIError): subject.iot_dps_registration_delete(None, registration_id, mock_target['entity'], resource_group)