diff --git a/azure-mgmt-iothubprovisioningservices/HISTORY.rst b/azure-mgmt-iothubprovisioningservices/HISTORY.rst new file mode 100644 index 000000000000..0873587ebf73 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (2018-01-04) +++++++++++++++++++ + +* Initial Release diff --git a/azure-mgmt-iothubprovisioningservices/MANIFEST.in b/azure-mgmt-iothubprovisioningservices/MANIFEST.in new file mode 100644 index 000000000000..9ecaeb15de50 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/MANIFEST.in @@ -0,0 +1,2 @@ +include *.rst +include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-mgmt-iothubprovisioningservices/README.rst b/azure-mgmt-iothubprovisioningservices/README.rst new file mode 100644 index 000000000000..aeb61dac5e38 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/README.rst @@ -0,0 +1,49 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure IoTHub Provisioning Services Client Library. + +Azure Resource Manager (ARM) is the next generation of management APIs that +replace the old Azure Service Management (ASM). + +This package has been tested with Python 2.7, 3.4, 3.5 and 3.6. + +For the older Azure Service Management (ASM) libraries, see +`azure-servicemanagement-legacy `__ library. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Compatibility +============= + +**IMPORTANT**: If you have an earlier version of the azure package +(version < 1.0), you should uninstall it before installing this package. + +You can check the version using pip: + +.. code:: shell + + pip freeze + +If you see azure==0.11.0 (or any version below 1.0), uninstall it first: + +.. code:: shell + + pip uninstall azure + + +Usage +===== + +For code examples, see `IoTHub Provisioning Services +`__ +on readthedocs.org. + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. diff --git a/azure-mgmt-iothubprovisioningservices/azure/__init__.py b/azure-mgmt-iothubprovisioningservices/azure/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/__init__.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py new file mode 100644 index 000000000000..908617c53e25 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__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 .iot_dps_client import IotDpsClient +from .version import VERSION + +__all__ = ['IotDpsClient'] + +__version__ = VERSION + diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/iot_dps_client.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/iot_dps_client.py new file mode 100644 index 000000000000..50e9cb6a57de --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/iot_dps_client.py @@ -0,0 +1,96 @@ +# 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 ServiceClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from .operations.operations import Operations +from .operations.dps_certificate_operations import DpsCertificateOperations +from .operations.iot_dps_resource_operations import IotDpsResourceOperations +from .operations.dps_certificates_operations import DpsCertificatesOperations +from . import models + + +class IotDpsClientConfiguration(AzureConfiguration): + """Configuration for IotDpsClient + 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 subscription_id: The subscription identifier. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(IotDpsClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-mgmt-iothubprovisioningservices/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id + + +class IotDpsClient(object): + """API for using the Azure IoT Hub Device Provisioning Service features. + + :ivar config: Configuration for client. + :vartype config: IotDpsClientConfiguration + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothubprovisioningservices.operations.Operations + :ivar dps_certificate: DpsCertificate operations + :vartype dps_certificate: azure.mgmt.iothubprovisioningservices.operations.DpsCertificateOperations + :ivar iot_dps_resource: IotDpsResource operations + :vartype iot_dps_resource: azure.mgmt.iothubprovisioningservices.operations.IotDpsResourceOperations + :ivar dps_certificates: DpsCertificates operations + :vartype dps_certificates: azure.mgmt.iothubprovisioningservices.operations.DpsCertificatesOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The subscription identifier. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = IotDpsClientConfiguration(credentials, subscription_id, 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 = '2017-11-15' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) + self.dps_certificate = DpsCertificateOperations( + self._client, self.config, self._serialize, self._deserialize) + self.iot_dps_resource = IotDpsResourceOperations( + self._client, self.config, self._serialize, self._deserialize) + self.dps_certificates = DpsCertificatesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py new file mode 100644 index 000000000000..46b354eaac2a --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py @@ -0,0 +1,80 @@ +# 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 .error_messsage import ErrorMesssage +from .async_operation_result import AsyncOperationResult +from .certificate_properties import CertificateProperties +from .certificate_response import CertificateResponse +from .certificate_list_description import CertificateListDescription +from .certificate_body_description import CertificateBodyDescription +from .iot_dps_sku_info import IotDpsSkuInfo +from .iot_hub_definition_description import IotHubDefinitionDescription +from .shared_access_signature_authorization_rule_access_rights_description import SharedAccessSignatureAuthorizationRuleAccessRightsDescription +from .iot_dps_properties_description import IotDpsPropertiesDescription +from .provisioning_service_description import ProvisioningServiceDescription +from .resource import Resource +from .operation_display import OperationDisplay +from .operation import Operation +from .error_details import ErrorDetails, ErrorDetailsException +from .iot_dps_sku_definition import IotDpsSkuDefinition +from .operation_inputs import OperationInputs +from .name_availability_info import NameAvailabilityInfo +from .tags_resource import TagsResource +from .verification_code_response_properties import VerificationCodeResponseProperties +from .verification_code_response import VerificationCodeResponse +from .verification_code_request import VerificationCodeRequest +from .operation_paged import OperationPaged +from .provisioning_service_description_paged import ProvisioningServiceDescriptionPaged +from .iot_dps_sku_definition_paged import IotDpsSkuDefinitionPaged +from .shared_access_signature_authorization_rule_access_rights_description_paged import SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged +from .iot_dps_client_enums import ( + IotDpsSku, + State, + AllocationPolicy, + AccessRightsDescription, + NameUnavailabilityReason, + CertificatePurpose, +) + +__all__ = [ + 'ErrorMesssage', + 'AsyncOperationResult', + 'CertificateProperties', + 'CertificateResponse', + 'CertificateListDescription', + 'CertificateBodyDescription', + 'IotDpsSkuInfo', + 'IotHubDefinitionDescription', + 'SharedAccessSignatureAuthorizationRuleAccessRightsDescription', + 'IotDpsPropertiesDescription', + 'ProvisioningServiceDescription', + 'Resource', + 'OperationDisplay', + 'Operation', + 'ErrorDetails', 'ErrorDetailsException', + 'IotDpsSkuDefinition', + 'OperationInputs', + 'NameAvailabilityInfo', + 'TagsResource', + 'VerificationCodeResponseProperties', + 'VerificationCodeResponse', + 'VerificationCodeRequest', + 'OperationPaged', + 'ProvisioningServiceDescriptionPaged', + 'IotDpsSkuDefinitionPaged', + 'SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged', + 'IotDpsSku', + 'State', + 'AllocationPolicy', + 'AccessRightsDescription', + 'NameUnavailabilityReason', + 'CertificatePurpose', +] diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/async_operation_result.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/async_operation_result.py new file mode 100644 index 000000000000..2daef701ad66 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/async_operation_result.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 AsyncOperationResult(Model): + """Result of a long running operation. + + :param status: current status of a long running operation. + :type status: str + :param error: Error message containing code, description and details + :type error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorMesssage'}, + } + + def __init__(self, status=None, error=None): + super(AsyncOperationResult, self).__init__() + self.status = status + self.error = error diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_body_description.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_body_description.py new file mode 100644 index 000000000000..6197ca0e0e28 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_body_description.py @@ -0,0 +1,29 @@ +# 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 CertificateBodyDescription(Model): + """The JSON-serialized X509 Certificate. + + :param certificate: Base-64 representation of the X509 leaf certificate + .cer file or just .pem file content. + :type certificate: str + """ + + _attribute_map = { + 'certificate': {'key': 'certificate', 'type': 'str'}, + } + + def __init__(self, certificate=None): + super(CertificateBodyDescription, self).__init__() + self.certificate = certificate diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_list_description.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_list_description.py new file mode 100644 index 000000000000..5d24e2c49cbd --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_list_description.py @@ -0,0 +1,29 @@ +# 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 CertificateListDescription(Model): + """The JSON-serialized array of Certificate objects. + + :param value: The array of Certificate objects. + :type value: + list[~azure.mgmt.iothubprovisioningservices.models.CertificateResponse] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CertificateResponse]'}, + } + + def __init__(self, value=None): + super(CertificateListDescription, self).__init__() + self.value = value diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_properties.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_properties.py new file mode 100644 index 000000000000..1fdcae65a127 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_properties.py @@ -0,0 +1,60 @@ +# 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 CertificateProperties(Model): + """The description of an X509 CA Certificate. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's creation date and time. + :vartype created: datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: datetime + """ + + _validation = { + 'subject': {'readonly': True}, + 'expiry': {'readonly': True}, + 'thumbprint': {'readonly': True}, + 'is_verified': {'readonly': True}, + 'created': {'readonly': True}, + 'updated': {'readonly': True}, + } + + _attribute_map = { + 'subject': {'key': 'subject', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, + 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + 'is_verified': {'key': 'isVerified', 'type': 'bool'}, + 'created': {'key': 'created', 'type': 'rfc-1123'}, + 'updated': {'key': 'updated', 'type': 'rfc-1123'}, + } + + def __init__(self): + super(CertificateProperties, self).__init__() + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = None + self.created = None + self.updated = None diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_response.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_response.py new file mode 100644 index 000000000000..2a3469f3e057 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/certificate_response.py @@ -0,0 +1,55 @@ +# 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 CertificateResponse(Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param properties: properties of a certificate + :type properties: + ~azure.mgmt.iothubprovisioningservices.models.CertificateProperties + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'etag': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, properties=None): + super(CertificateResponse, self).__init__() + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/error_details.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/error_details.py new file mode 100644 index 000000000000..6aed72f0d774 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/error_details.py @@ -0,0 +1,63 @@ +# 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 ErrorDetails(Model): + """Error details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar http_status_code: The HTTP status code. + :vartype http_status_code: str + :ivar message: The error message. + :vartype message: str + :ivar details: The error details. + :vartype details: str + """ + + _validation = { + 'code': {'readonly': True}, + 'http_status_code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'Code', 'type': 'str'}, + 'http_status_code': {'key': 'HttpStatusCode', 'type': 'str'}, + 'message': {'key': 'Message', 'type': 'str'}, + 'details': {'key': 'Details', 'type': 'str'}, + } + + def __init__(self): + super(ErrorDetails, self).__init__() + self.code = None + self.http_status_code = None + self.message = None + self.details = None + + +class ErrorDetailsException(HttpOperationError): + """Server responsed with exception of type: 'ErrorDetails'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorDetailsException, self).__init__(deserialize, response, 'ErrorDetails', *args) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/error_messsage.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/error_messsage.py new file mode 100644 index 000000000000..a8daa5f398dc --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/error_messsage.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 ErrorMesssage(Model): + """Error response containing message and code. + + :param code: standard error code + :type code: str + :param message: standard error description + :type message: str + :param details: detailed summary of error + :type details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__(self, code=None, message=None, details=None): + super(ErrorMesssage, self).__init__() + self.code = code + self.message = message + self.details = details diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_client_enums.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_client_enums.py new file mode 100644 index 000000000000..bf6316aebd74 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_client_enums.py @@ -0,0 +1,62 @@ +# 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 enum import Enum + + +class IotDpsSku(Enum): + + s1 = "S1" + + +class State(Enum): + + activating = "Activating" + active = "Active" + deleting = "Deleting" + deleted = "Deleted" + activation_failed = "ActivationFailed" + deletion_failed = "DeletionFailed" + transitioning = "Transitioning" + suspending = "Suspending" + suspended = "Suspended" + resuming = "Resuming" + failing_over = "FailingOver" + failover_failed = "FailoverFailed" + + +class AllocationPolicy(Enum): + + hashed = "Hashed" + geo_latency = "GeoLatency" + static = "Static" + + +class AccessRightsDescription(Enum): + + service_config = "ServiceConfig" + enrollment_read = "EnrollmentRead" + enrollment_write = "EnrollmentWrite" + device_connect = "DeviceConnect" + registration_status_read = "RegistrationStatusRead" + registration_status_write = "RegistrationStatusWrite" + + +class NameUnavailabilityReason(Enum): + + invalid = "Invalid" + already_exists = "AlreadyExists" + + +class CertificatePurpose(Enum): + + client_authentication = "clientAuthentication" + server_authentication = "serverAuthentication" diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_properties_description.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_properties_description.py new file mode 100644 index 000000000000..21e496ad6608 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_properties_description.py @@ -0,0 +1,80 @@ +# 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 IotDpsPropertiesDescription(Model): + """the service specific properties of a provisoning service, including keys, + linked iot hubs, current state, and system generated properties such as + hostname and idScope. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param state: Current state of the provisioning service. Possible values + include: 'Activating', 'Active', 'Deleting', 'Deleted', + 'ActivationFailed', 'DeletionFailed', 'Transitioning', 'Suspending', + 'Suspended', 'Resuming', 'FailingOver', 'FailoverFailed' + :type state: str or ~azure.mgmt.iothubprovisioningservices.models.State + :param provisioning_state: The ARM provisioning state of the provisioning + service. + :type provisioning_state: str + :param iot_hubs: List of IoT hubs assosciated with this provisioning + service. + :type iot_hubs: + list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] + :param allocation_policy: Allocation policy to be used by this + provisioning service. Possible values include: 'Hashed', 'GeoLatency', + 'Static' + :type allocation_policy: str or + ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy + :ivar service_operations_host_name: Service endpoint for provisioning + service. + :vartype service_operations_host_name: str + :ivar device_provisioning_host_name: Device endpoint for this provisioning + service. + :vartype device_provisioning_host_name: str + :ivar id_scope: Unique identifier of this provisioning service. + :vartype id_scope: str + :param authorization_policies: List of authorization keys for a + provisioning service. + :type authorization_policies: + list[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + """ + + _validation = { + 'service_operations_host_name': {'readonly': True}, + 'device_provisioning_host_name': {'readonly': True}, + 'id_scope': {'readonly': True}, + } + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'iot_hubs': {'key': 'iotHubs', 'type': '[IotHubDefinitionDescription]'}, + 'allocation_policy': {'key': 'allocationPolicy', 'type': 'str'}, + 'service_operations_host_name': {'key': 'serviceOperationsHostName', 'type': 'str'}, + 'device_provisioning_host_name': {'key': 'deviceProvisioningHostName', 'type': 'str'}, + 'id_scope': {'key': 'idScope', 'type': 'str'}, + 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'}, + } + + def __init__(self, state=None, provisioning_state=None, iot_hubs=None, allocation_policy=None, authorization_policies=None): + super(IotDpsPropertiesDescription, self).__init__() + self.state = state + self.provisioning_state = provisioning_state + self.iot_hubs = iot_hubs + self.allocation_policy = allocation_policy + self.service_operations_host_name = None + self.device_provisioning_host_name = None + self.id_scope = None + self.authorization_policies = authorization_policies diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_definition.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_definition.py new file mode 100644 index 000000000000..ad8157638c07 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_definition.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 IotDpsSkuDefinition(Model): + """Available Sku's of tier and units. + + :param name: Sku name. Possible values include: 'S1' + :type name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, name=None): + super(IotDpsSkuDefinition, self).__init__() + self.name = name diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_definition_paged.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_definition_paged.py new file mode 100644 index 000000000000..981f1fb2599a --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_definition_paged.py @@ -0,0 +1,27 @@ +# 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.paging import Paged + + +class IotDpsSkuDefinitionPaged(Paged): + """ + A paging container for iterating over a list of :class:`IotDpsSkuDefinition ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[IotDpsSkuDefinition]'} + } + + def __init__(self, *args, **kwargs): + + super(IotDpsSkuDefinitionPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_info.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_info.py new file mode 100644 index 000000000000..5061c70ef609 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_dps_sku_info.py @@ -0,0 +1,43 @@ +# 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 IotDpsSkuInfo(Model): + """List of possible provisoning service SKUs. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param name: Sku name. Possible values include: 'S1' + :type name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku + :ivar tier: Pricing tier name of the provisioning service. + :vartype tier: str + :param capacity: The number of units to provision + :type capacity: long + """ + + _validation = { + 'tier': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'long'}, + } + + def __init__(self, name=None, capacity=None): + super(IotDpsSkuInfo, self).__init__() + self.name = name + self.tier = None + self.capacity = capacity diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_hub_definition_description.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_hub_definition_description.py new file mode 100644 index 000000000000..13edb260301b --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/iot_hub_definition_description.py @@ -0,0 +1,54 @@ +# 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 IotHubDefinitionDescription(Model): + """Description of the IoT hub. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param apply_allocation_policy: flag for applying allocationPolicy or not + for a given iot hub. + :type apply_allocation_policy: bool + :param allocation_weight: weight to apply for a given iot h. + :type allocation_weight: int + :ivar name: Host name of the IoT hub. + :vartype name: str + :param connection_string: Connection string og the IoT hub. + :type connection_string: str + :param location: ARM region of the IoT hub. + :type location: str + """ + + _validation = { + 'name': {'readonly': True}, + 'connection_string': {'required': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'apply_allocation_policy': {'key': 'applyAllocationPolicy', 'type': 'bool'}, + 'allocation_weight': {'key': 'allocationWeight', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'str'}, + 'connection_string': {'key': 'connectionString', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__(self, connection_string, location, apply_allocation_policy=None, allocation_weight=None): + super(IotHubDefinitionDescription, self).__init__() + self.apply_allocation_policy = apply_allocation_policy + self.allocation_weight = allocation_weight + self.name = None + self.connection_string = connection_string + self.location = location diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/name_availability_info.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/name_availability_info.py new file mode 100644 index 000000000000..a189ee6cebc1 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/name_availability_info.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 NameAvailabilityInfo(Model): + """Description of name availability. + + :param name_available: specifies if a name is available or not + :type name_available: bool + :param reason: specifies the reason a name is unavailable. Possible values + include: 'Invalid', 'AlreadyExists' + :type reason: str or + ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason + :param message: message containing a etailed reason name is unavailable + :type message: str + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, name_available=None, reason=None, message=None): + super(NameAvailabilityInfo, self).__init__() + self.name_available = name_available + self.reason = reason + self.message = message diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation.py new file mode 100644 index 000000000000..ccc988e66dc6 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation.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 Operation(Model): + """IoT Hub REST API operation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: Operation name: {provider}/{resource}/{read | write | action | + delete} + :vartype name: str + :param display: The object that represents the operation. + :type display: + ~azure.mgmt.iothubprovisioningservices.models.OperationDisplay + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, display=None): + super(Operation, self).__init__() + self.name = None + self.display = display diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_display.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_display.py new file mode 100644 index 000000000000..3350c343e3c3 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_display.py @@ -0,0 +1,45 @@ +# 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 OperationDisplay(Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar provider: Service provider: Microsoft Devices. + :vartype provider: str + :ivar resource: Resource Type: ProvisioningServices. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__(self): + super(OperationDisplay, self).__init__() + self.provider = None + self.resource = None + self.operation = None diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_inputs.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_inputs.py new file mode 100644 index 000000000000..6f2016b41ca7 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_inputs.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 OperationInputs(Model): + """Input values for operation results call. + + :param name: The name of the Provisioning Service to check. + :type name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, name): + super(OperationInputs, self).__init__() + self.name = name diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_paged.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_paged.py new file mode 100644 index 000000000000..3f6c7fbeb755 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/operation_paged.py @@ -0,0 +1,27 @@ +# 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.paging import Paged + + +class OperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Operation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Operation]'} + } + + def __init__(self, *args, **kwargs): + + super(OperationPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/provisioning_service_description.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/provisioning_service_description.py new file mode 100644 index 000000000000..f99dc12191fc --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/provisioning_service_description.py @@ -0,0 +1,66 @@ +# 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 .resource import Resource + + +class ProvisioningServiceDescription(Resource): + """The description of the provisioning service. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :param location: The resource location. + :type location: str + :param tags: The resource tags. + :type tags: dict[str, str] + :param etag: The Etag field is *not* required. If it is provided in the + response body, it must also be provided as a header per the normal ETag + convention. + :type etag: str + :param properties: Service specific properties for a provisioning service + :type properties: + ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription + :param sku: Sku info for a provisioning Service. + :type sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'properties': {'required': True}, + 'sku': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'IotDpsPropertiesDescription'}, + 'sku': {'key': 'sku', 'type': 'IotDpsSkuInfo'}, + } + + def __init__(self, location, properties, sku, tags=None, etag=None): + super(ProvisioningServiceDescription, self).__init__(location=location, tags=tags) + self.etag = etag + self.properties = properties + self.sku = sku diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/provisioning_service_description_paged.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/provisioning_service_description_paged.py new file mode 100644 index 000000000000..3f10e4fdb0d5 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/provisioning_service_description_paged.py @@ -0,0 +1,27 @@ +# 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.paging import Paged + + +class ProvisioningServiceDescriptionPaged(Paged): + """ + A paging container for iterating over a list of :class:`ProvisioningServiceDescription ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ProvisioningServiceDescription]'} + } + + def __init__(self, *args, **kwargs): + + super(ProvisioningServiceDescriptionPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/resource.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/resource.py new file mode 100644 index 000000000000..19274f71456d --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/resource.py @@ -0,0 +1,54 @@ +# 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 Resource(Model): + """The common properties of an Azure resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :param location: The resource location. + :type location: str + :param tags: The resource tags. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, location, tags=None): + super(Resource, self).__init__() + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/shared_access_signature_authorization_rule_access_rights_description.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/shared_access_signature_authorization_rule_access_rights_description.py new file mode 100644 index 000000000000..6464df7ce3a8 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/shared_access_signature_authorization_rule_access_rights_description.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 SharedAccessSignatureAuthorizationRuleAccessRightsDescription(Model): + """Description of the shared access key. + + :param key_name: Name of the key. + :type key_name: str + :param primary_key: Primary SAS key value. + :type primary_key: str + :param secondary_key: Secondary SAS key value. + :type secondary_key: str + :param rights: Rights that this key has. Possible values include: + 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', 'DeviceConnect', + 'RegistrationStatusRead', 'RegistrationStatusWrite' + :type rights: str or + ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription + """ + + _validation = { + 'key_name': {'required': True}, + 'rights': {'required': True}, + } + + _attribute_map = { + 'key_name': {'key': 'keyName', 'type': 'str'}, + 'primary_key': {'key': 'primaryKey', 'type': 'str'}, + 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, + 'rights': {'key': 'rights', 'type': 'str'}, + } + + def __init__(self, key_name, rights, primary_key=None, secondary_key=None): + super(SharedAccessSignatureAuthorizationRuleAccessRightsDescription, self).__init__() + self.key_name = key_name + self.primary_key = primary_key + self.secondary_key = secondary_key + self.rights = rights diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/shared_access_signature_authorization_rule_access_rights_description_paged.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/shared_access_signature_authorization_rule_access_rights_description_paged.py new file mode 100644 index 000000000000..3223713a25e7 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/shared_access_signature_authorization_rule_access_rights_description_paged.py @@ -0,0 +1,27 @@ +# 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.paging import Paged + + +class SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged(Paged): + """ + A paging container for iterating over a list of :class:`SharedAccessSignatureAuthorizationRuleAccessRightsDescription ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'} + } + + def __init__(self, *args, **kwargs): + + super(SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/tags_resource.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/tags_resource.py new file mode 100644 index 000000000000..0fe5569ba490 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/tags_resource.py @@ -0,0 +1,29 @@ +# 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 TagsResource(Model): + """A container holding only the Tags for a resource, allowing the user to + update the tags on a Provisioning Service instance. + + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, tags=None): + super(TagsResource, self).__init__() + self.tags = tags diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_request.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_request.py new file mode 100644 index 000000000000..37a3e5cc266b --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_request.py @@ -0,0 +1,29 @@ +# 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 VerificationCodeRequest(Model): + """The JSON-serialized leaf certificate. + + :param certificate: base-64 representation of X509 certificate .cer file + or just .pem file content. + :type certificate: str + """ + + _attribute_map = { + 'certificate': {'key': 'certificate', 'type': 'str'}, + } + + def __init__(self, certificate=None): + super(VerificationCodeRequest, self).__init__() + self.certificate = certificate diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_response.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_response.py new file mode 100644 index 000000000000..cf935cbf647f --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_response.py @@ -0,0 +1,55 @@ +# 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 VerificationCodeResponse(Model): + """Description of the response of the verification code. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: Name of certificate. + :vartype name: str + :ivar etag: Request etag. + :vartype etag: str + :ivar id: The resource identifier. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :param properties: + :type properties: + ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponseProperties + """ + + _validation = { + 'name': {'readonly': True}, + 'etag': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'VerificationCodeResponseProperties'}, + } + + def __init__(self, properties=None): + super(VerificationCodeResponse, self).__init__() + self.name = None + self.etag = None + self.id = None + self.type = None + self.properties = properties diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_response_properties.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_response_properties.py new file mode 100644 index 000000000000..d40898cfa743 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/verification_code_response_properties.py @@ -0,0 +1,53 @@ +# 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 VerificationCodeResponseProperties(Model): + """VerificationCodeResponseProperties. + + :param verification_code: Verification code. + :type verification_code: str + :param subject: Certificate subject. + :type subject: str + :param expiry: Code expiry. + :type expiry: str + :param thumbprint: Certificate thumbprint. + :type thumbprint: str + :param is_verified: Indicate if the certificate is verified by owner of + private key. + :type is_verified: bool + :param created: Certificate created time. + :type created: str + :param updated: Certificate updated time. + :type updated: str + """ + + _attribute_map = { + 'verification_code': {'key': 'verificationCode', 'type': 'str'}, + 'subject': {'key': 'subject', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'str'}, + 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + 'is_verified': {'key': 'isVerified', 'type': 'bool'}, + 'created': {'key': 'created', 'type': 'str'}, + 'updated': {'key': 'updated', 'type': 'str'}, + } + + def __init__(self, verification_code=None, subject=None, expiry=None, thumbprint=None, is_verified=None, created=None, updated=None): + super(VerificationCodeResponseProperties, self).__init__() + self.verification_code = verification_code + self.subject = subject + self.expiry = expiry + self.thumbprint = thumbprint + self.is_verified = is_verified + self.created = created + self.updated = updated diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py new file mode 100644 index 000000000000..841e1f3dd6e1 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py @@ -0,0 +1,22 @@ +# 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 .operations import Operations +from .dps_certificate_operations import DpsCertificateOperations +from .iot_dps_resource_operations import IotDpsResourceOperations +from .dps_certificates_operations import DpsCertificatesOperations + +__all__ = [ + 'Operations', + 'DpsCertificateOperations', + 'IotDpsResourceOperations', + 'DpsCertificatesOperations', +] diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/dps_certificate_operations.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/dps_certificate_operations.py new file mode 100644 index 000000000000..7201d5ff42d5 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/dps_certificate_operations.py @@ -0,0 +1,516 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class DpsCertificateOperations(object): + """DpsCertificateOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: The version of the API. Constant value: "2017-11-15". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-11-15" + + self.config = config + + def get( + self, certificate_name, resource_group_name, provisioning_service_name, if_match=None, custom_headers=None, raw=False, **operation_config): + """Get the certificate from the provisioning service. + + :param certificate_name: Name of the certificate to retrieve. + :type certificate_name: str + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param provisioning_service_name: Name of the provisioning service the + certificate is associated with. + :type provisioning_service_name: str + :param if_match: ETag of the certificate. + :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: CertificateResponse or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}' + path_format_arguments = { + 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, '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.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CertificateResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, provisioning_service_name, certificate_name, if_match=None, certificate=None, custom_headers=None, raw=False, **operation_config): + """Upload the certificate to the provisioning service. + + Add new certificate or update an existing certificate. + + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param provisioning_service_name: The name of the provisioning + service. + :type provisioning_service_name: str + :param certificate_name: The name of the certificate create or update. + :type certificate_name: str + :param if_match: ETag of the certificate. This is required to update + an existing certificate, and ignored while creating a brand new + certificate. + :type if_match: str + :param certificate: Base-64 representation of the X509 leaf + certificate .cer file or just .pem file content. + :type certificate: 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: CertificateResponse or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + certificate_description = models.CertificateBodyDescription(certificate=certificate) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', max_length=256) + } + 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(certificate_description, 'CertificateBodyDescription') + + # 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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CertificateResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def delete( + self, resource_group_name, if_match, provisioning_service_name, certificate_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, custom_headers=None, raw=False, **operation_config): + """Delete the Provisioning Service Certificate. + + Deletes the specified certificate assosciated with the Provisioning + Service. + + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param if_match: ETag of the certificate + :type if_match: str + :param provisioning_service_name: The name of the provisioning + service. + :type provisioning_service_name: str + :param certificate_name: This is a mandatory field, and is the logical + name of the certificate that the provisioning service will access by. + :type certificate_name: str + :param certificatename: This is optional, and it is the Common Name of + the certificate. + :type certificatename: str + :param certificateraw_bytes: Raw data within the certificate. + :type certificateraw_bytes: bytearray + :param certificateis_verified: Indicates if certificate has been + verified by owner of the private key. + :type certificateis_verified: bool + :param certificatepurpose: A description that mentions the purpose of + the certificate. Possible values include: 'clientAuthentication', + 'serverAuthentication' + :type certificatepurpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificatecreated: Time the certificate is created. + :type certificatecreated: datetime + :param certificatelast_updated: Time the certificate is last updated. + :type certificatelast_updated: datetime + :param certificatehas_private_key: Indicates if the certificate + contains a private key. + :type certificatehas_private_key: bool + :param certificatenonce: Random number generated to indicate Proof of + Possession. + :type certificatenonce: 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:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if certificatename is not None: + query_parameters['certificate.name'] = self._serialize.query("certificatename", certificatename, 'str') + if certificateraw_bytes is not None: + query_parameters['certificate.rawBytes'] = self._serialize.query("certificateraw_bytes", certificateraw_bytes, 'bytearray') + if certificateis_verified is not None: + query_parameters['certificate.isVerified'] = self._serialize.query("certificateis_verified", certificateis_verified, 'bool') + if certificatepurpose is not None: + query_parameters['certificate.purpose'] = self._serialize.query("certificatepurpose", certificatepurpose, 'str') + if certificatecreated is not None: + query_parameters['certificate.created'] = self._serialize.query("certificatecreated", certificatecreated, 'iso-8601') + if certificatelast_updated is not None: + query_parameters['certificate.lastUpdated'] = self._serialize.query("certificatelast_updated", certificatelast_updated, 'iso-8601') + if certificatehas_private_key is not None: + query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificatehas_private_key", certificatehas_private_key, 'bool') + if certificatenonce is not None: + query_parameters['certificate.nonce'] = self._serialize.query("certificatenonce", certificatenonce, 'str') + 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) + 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 [200, 204]: + raise models.ErrorDetailsException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def generate_verification_code( + self, certificate_name, if_match, resource_group_name, provisioning_service_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, custom_headers=None, raw=False, **operation_config): + """Generate verification code for Proof of Possession. + + :param certificate_name: The mandatory logical name of the + certificate, that the provisioning service uses to access. + :type certificate_name: str + :param if_match: ETag of the certificate. This is required to update + an existing certificate, and ignored while creating a brand new + certificate. + :type if_match: str + :param resource_group_name: name of resource group. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service. + :type provisioning_service_name: str + :param certificatename: Common Name for the certificate. + :type certificatename: str + :param certificateraw_bytes: Raw data of certificate. + :type certificateraw_bytes: bytearray + :param certificateis_verified: Indicates if the certificate has been + verified by owner of the private key. + :type certificateis_verified: bool + :param certificatepurpose: Description mentioning the purpose of the + certificate. Possible values include: 'clientAuthentication', + 'serverAuthentication' + :type certificatepurpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificatecreated: Certificate creation time. + :type certificatecreated: datetime + :param certificatelast_updated: Certificate last updated time. + :type certificatelast_updated: datetime + :param certificatehas_private_key: Indicates if the certificate + contains private key. + :type certificatehas_private_key: bool + :param certificatenonce: Random number generated to indicate Proof of + Possession. + :type certificatenonce: 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: VerificationCodeResponse or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponse + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode' + path_format_arguments = { + 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if certificatename is not None: + query_parameters['certificate.name'] = self._serialize.query("certificatename", certificatename, 'str') + if certificateraw_bytes is not None: + query_parameters['certificate.rawBytes'] = self._serialize.query("certificateraw_bytes", certificateraw_bytes, 'bytearray') + if certificateis_verified is not None: + query_parameters['certificate.isVerified'] = self._serialize.query("certificateis_verified", certificateis_verified, 'bool') + if certificatepurpose is not None: + query_parameters['certificate.purpose'] = self._serialize.query("certificatepurpose", certificatepurpose, 'str') + if certificatecreated is not None: + query_parameters['certificate.created'] = self._serialize.query("certificatecreated", certificatecreated, 'iso-8601') + if certificatelast_updated is not None: + query_parameters['certificate.lastUpdated'] = self._serialize.query("certificatelast_updated", certificatelast_updated, 'iso-8601') + if certificatehas_private_key is not None: + query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificatehas_private_key", certificatehas_private_key, 'bool') + if certificatenonce is not None: + query_parameters['certificate.nonce'] = self._serialize.query("certificatenonce", certificatenonce, 'str') + 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) + 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.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('VerificationCodeResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def verify_certificate( + self, certificate_name, if_match, resource_group_name, provisioning_service_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, certificate=None, custom_headers=None, raw=False, **operation_config): + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf + cert issued by the verifying pre uploaded certificate. + + :param certificate_name: The mandatory logical name of the + certificate, that the provisioning service uses to access. + :type certificate_name: str + :param if_match: ETag of the certificate. + :type if_match: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param provisioning_service_name: Provisioning service name. + :type provisioning_service_name: str + :param certificatename: Common Name for the certificate. + :type certificatename: str + :param certificateraw_bytes: Raw data of certificate. + :type certificateraw_bytes: bytearray + :param certificateis_verified: Indicates if the certificate has been + verified by owner of the private key. + :type certificateis_verified: bool + :param certificatepurpose: Describe the purpose of the certificate. + Possible values include: 'clientAuthentication', + 'serverAuthentication' + :type certificatepurpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificatecreated: Certificate creation time. + :type certificatecreated: datetime + :param certificatelast_updated: Certificate last updated time. + :type certificatelast_updated: datetime + :param certificatehas_private_key: Indicates if the certificate + contains private key. + :type certificatehas_private_key: bool + :param certificatenonce: Random number generated to indicate Proof of + Possession. + :type certificatenonce: str + :param certificate: base-64 representation of X509 certificate .cer + file or just .pem file content. + :type certificate: 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: CertificateResponse or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + request = models.VerificationCodeRequest(certificate=certificate) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify' + path_format_arguments = { + 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if certificatename is not None: + query_parameters['certificate.name'] = self._serialize.query("certificatename", certificatename, 'str') + if certificateraw_bytes is not None: + query_parameters['certificate.rawBytes'] = self._serialize.query("certificateraw_bytes", certificateraw_bytes, 'bytearray') + if certificateis_verified is not None: + query_parameters['certificate.isVerified'] = self._serialize.query("certificateis_verified", certificateis_verified, 'bool') + if certificatepurpose is not None: + query_parameters['certificate.purpose'] = self._serialize.query("certificatepurpose", certificatepurpose, 'str') + if certificatecreated is not None: + query_parameters['certificate.created'] = self._serialize.query("certificatecreated", certificatecreated, 'iso-8601') + if certificatelast_updated is not None: + query_parameters['certificate.lastUpdated'] = self._serialize.query("certificatelast_updated", certificatelast_updated, 'iso-8601') + if certificatehas_private_key is not None: + query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificatehas_private_key", certificatehas_private_key, 'bool') + if certificatenonce is not None: + query_parameters['certificate.nonce'] = self._serialize.query("certificatenonce", certificatenonce, 'str') + 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) + 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(request, 'VerificationCodeRequest') + + # 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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CertificateResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/dps_certificates_operations.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/dps_certificates_operations.py new file mode 100644 index 000000000000..d0d34c27cec8 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/dps_certificates_operations.py @@ -0,0 +1,99 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class DpsCertificatesOperations(object): + """DpsCertificatesOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: The version of the API. Constant value: "2017-11-15". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-11-15" + + self.config = config + + def list( + self, resource_group_name, provisioning_service_name, custom_headers=None, raw=False, **operation_config): + """Get all the certificates tied to the provisioning service. + + :param resource_group_name: Name of resource group. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to + retrieve certificates for. + :type provisioning_service_name: 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: CertificateListDescription or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.CertificateListDescription + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, '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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CertificateListDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/iot_dps_resource_operations.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/iot_dps_resource_operations.py new file mode 100644 index 000000000000..949fd8e24bfe --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/iot_dps_resource_operations.py @@ -0,0 +1,930 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError +from msrestazure.azure_operation import AzureOperationPoller + +from .. import models + + +class IotDpsResourceOperations(object): + """IotDpsResourceOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: The version of the API. Constant value: "2017-11-15". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-11-15" + + self.config = config + + def get( + self, provisioning_service_name, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Get the non-security related metadata of the provisioning service. + + Get the metadata of the provisioning service without SAS keys. + + :param provisioning_service_name: Name of the provisioning service to + retrieve. + :type provisioning_service_name: str + :param resource_group_name: Resource group name. + :type resource_group_name: 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: ProvisioningServiceDescription or ClientRawResponse if + raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}' + path_format_arguments = { + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ProvisioningServiceDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + + def _create_or_update_initial( + self, resource_group_name, provisioning_service_name, iot_dps_description, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, '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 body + body_content = self._serialize.body(iot_dps_description, 'ProvisioningServiceDescription') + + # 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, 201]: + raise models.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ProvisioningServiceDescription', response) + if response.status_code == 201: + deserialized = self._deserialize('ProvisioningServiceDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, provisioning_service_name, iot_dps_description, custom_headers=None, raw=False, **operation_config): + """Create or update the metadata of the provisioning service. + + Create or update the metadata of the provisioning service. The usual + pattern to modify a property is to retrieve the provisioning service + metadata and security metadata, and then combine them with the modified + values in a new body to update the provisioning service. + + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to + create or update. + :type provisioning_service_name: str + :param iot_dps_description: Description of the provisioning service to + create or update. + :type iot_dps_description: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ProvisioningServiceDescription or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + iot_dps_description=iot_dps_description, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 201]: + raise models.ErrorDetailsException(self._deserialize, response) + + deserialized = self._deserialize('ProvisioningServiceDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + + def _update_initial( + self, resource_group_name, provisioning_service_name, tags=None, custom_headers=None, raw=False, **operation_config): + provisioning_service_tags = models.TagsResource(tags=tags) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, '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 body + body_content = self._serialize.body(provisioning_service_tags, 'TagsResource') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ProvisioningServiceDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, provisioning_service_name, tags=None, custom_headers=None, raw=False, **operation_config): + """Update an existing provisioning service's tags. + + Update an existing provisioning service's tags. to update other fields + use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to + create or update. + :type provisioning_service_name: str + :param tags: Resource tags + :type tags: dict[str, str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ProvisioningServiceDescription or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._update_initial( + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + tags=tags, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = self._deserialize('ProvisioningServiceDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + + def _delete_initial( + self, provisioning_service_name, resource_group_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}' + path_format_arguments = { + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204, 404]: + raise models.ErrorDetailsException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def delete( + self, provisioning_service_name, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Delete the Provisioning Service. + + Deletes the Provisioning Service. + + :param provisioning_service_name: Name of provisioning service to + delete. + :type provisioning_service_name: str + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + raw_result = self._delete_initial( + provisioning_service_name=provisioning_service_name, + resource_group_name=resource_group_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 202, 204, 404]: + raise models.ErrorDetailsException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def list_by_subscription( + self, custom_headers=None, raw=False, **operation_config): + """Get all the provisioning services in a subscription. + + List all the provisioning services for a given subscription id. + + :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: An iterator like instance of ProvisioningServiceDescription + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises: + :class:`ErrorDetailsException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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') + + else: + url = next_link + query_parameters = {} + + # 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.ErrorDetailsException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.ProvisioningServiceDescriptionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.ProvisioningServiceDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def list_by_resource_group( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Get a list of all provisioning services in the given resource group. + + :param resource_group_name: Resource group identifier. + :type resource_group_name: 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: An iterator like instance of ProvisioningServiceDescription + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises: + :class:`ErrorDetailsException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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') + + else: + url = next_link + query_parameters = {} + + # 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.ErrorDetailsException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.ProvisioningServiceDescriptionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.ProvisioningServiceDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def get_operation_result( + self, operation_id, resource_group_name, provisioning_service_name, asyncinfo="true", custom_headers=None, raw=False, **operation_config): + """Gets the status of a long running operation, such as create, update or + delete a provisioning service. + + :param operation_id: Operation id corresponding to long running + operation. Use this to poll for the status. + :type operation_id: str + :param resource_group_name: Resource group identifier. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service that + the operation is running on. + :type provisioning_service_name: str + :param asyncinfo: Async header used to poll on the status of the + operation, obtained while creating the long running operation. + :type asyncinfo: 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: AsyncOperationResult or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.AsyncOperationResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}' + path_format_arguments = { + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['asyncinfo'] = self._serialize.query("asyncinfo", asyncinfo, 'str') + 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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('AsyncOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_valid_skus( + self, provisioning_service_name, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Get the list of valid SKUs for a provisioning service. + + Gets the list of valid SKUs and tiers for a provisioning service. + + :param provisioning_service_name: Name of provisioning service. + :type provisioning_service_name: str + :param resource_group_name: Name of resource group. + :type resource_group_name: 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: An iterator like instance of IotDpsSkuDefinition + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] + :raises: + :class:`ErrorDetailsException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus' + path_format_arguments = { + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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') + + else: + url = next_link + query_parameters = {} + + # 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.ErrorDetailsException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.IotDpsSkuDefinitionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.IotDpsSkuDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def check_provisioning_service_name_availability( + self, name, custom_headers=None, raw=False, **operation_config): + """Check if a provisioning service name is available. + + Check if a provisioning service name is available. This will validate + if the name is syntactically valid and if the name is usable. + + :param name: The name of the Provisioning Service to check. + :type name: 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: NameAvailabilityInfo or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + arguments = models.OperationInputs(name=name) + + # Construct URL + url = '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability' + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 body + body_content = self._serialize.body(arguments, 'OperationInputs') + + # 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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('NameAvailabilityInfo', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_keys( + self, provisioning_service_name, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Get the security metadata for a provisioning service. + + List the primary and secondary keys for a provisioning service. + + :param provisioning_service_name: The provisioning service name to get + the shared access keys for. + :type provisioning_service_name: str + :param resource_group_name: resource group name + :type resource_group_name: 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: An iterator like instance of + SharedAccessSignatureAuthorizationRuleAccessRightsDescription + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + :raises: + :class:`ErrorDetailsException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys' + path_format_arguments = { + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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') + + else: + url = next_link + query_parameters = {} + + # 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.ErrorDetailsException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def list_keys_for_key_name( + self, provisioning_service_name, key_name, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Get a shared access policy by name from a provisioning service. + + List primary and secondary keys for a specific key name. + + :param provisioning_service_name: Name of the provisioning service. + :type provisioning_service_name: str + :param key_name: Logical key name to get key-values for. + :type key_name: str + :param resource_group_name: The name of the resource group that + contains the provisioning service. + :type resource_group_name: 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: SharedAccessSignatureAuthorizationRuleAccessRightsDescription + or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorDetailsException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys' + path_format_arguments = { + 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), + 'keyName': self._serialize.url("key_name", key_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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.ErrorDetailsException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleAccessRightsDescription', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/operations.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/operations.py new file mode 100644 index 000000000000..2a4e49dd9751 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/operations.py @@ -0,0 +1,96 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class Operations(object): + """Operations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: The version of the API. Constant value: "2017-11-15". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-11-15" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all of the available Microsoft.Devices REST API operations. + + :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: An iterator like instance of Operation + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.OperationPaged[~azure.mgmt.iothubprovisioningservices.models.Operation] + :raises: + :class:`ErrorDetailsException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/providers/Microsoft.Devices/operations' + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # 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.ErrorDetailsException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/version.py b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/version.py new file mode 100644 index 000000000000..bc45ce5de9cd --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/version.py @@ -0,0 +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 = "2017-11-15" + diff --git a/azure-mgmt-iothubprovisioningservices/azure_bdist_wheel.py b/azure-mgmt-iothubprovisioningservices/azure_bdist_wheel.py new file mode 100644 index 000000000000..61ec571a9743 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/azure_bdist_wheel.py @@ -0,0 +1,533 @@ +""" +"wheel" copyright (c) 2012-2017 Daniel Holth and +contributors. + +The MIT License + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Create a Azure wheel (.whl) distribution (a wheel is a built archive format). + +This file is a copy of the official bdist_wheel file from wheel 0.30.0a0, enhanced +of the bottom with some Microsoft extension for Azure SDK for Python + +""" + +import csv +import hashlib +import os +import subprocess +import warnings +import shutil +import json +import sys + +try: + import sysconfig +except ImportError: # pragma nocover + # Python < 2.7 + import distutils.sysconfig as sysconfig + +import pkg_resources + +safe_name = pkg_resources.safe_name +safe_version = pkg_resources.safe_version + +from shutil import rmtree +from email.generator import Generator + +from distutils.core import Command +from distutils.sysconfig import get_python_version + +from distutils import log as logger + +from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag, get_platform +from wheel.util import native, open_for_csv +from wheel.archive import archive_wheelfile +from wheel.pkginfo import read_pkg_info, write_pkg_info +from wheel.metadata import pkginfo_to_dict +from wheel import pep425tags, metadata +from wheel import __version__ as wheel_version + +def safer_name(name): + return safe_name(name).replace('-', '_') + +def safer_version(version): + return safe_version(version).replace('-', '_') + +class bdist_wheel(Command): + + description = 'create a wheel distribution' + + user_options = [('bdist-dir=', 'b', + "temporary directory for creating the distribution"), + ('plat-name=', 'p', + "platform name to embed in generated filenames " + "(default: %s)" % get_platform()), + ('keep-temp', 'k', + "keep the pseudo-installation tree around after " + + "creating the distribution archive"), + ('dist-dir=', 'd', + "directory to put final built distributions in"), + ('skip-build', None, + "skip rebuilding everything (for testing/debugging)"), + ('relative', None, + "build the archive using relative paths" + "(default: false)"), + ('owner=', 'u', + "Owner name used when creating a tar file" + " [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file" + " [default: current group]"), + ('universal', None, + "make a universal wheel" + " (default: false)"), + ('python-tag=', None, + "Python implementation compatibility tag" + " (default: py%s)" % get_impl_ver()[0]), + ] + + boolean_options = ['keep-temp', 'skip-build', 'relative', 'universal'] + + def initialize_options(self): + self.bdist_dir = None + self.data_dir = None + self.plat_name = None + self.plat_tag = None + self.format = 'zip' + self.keep_temp = False + self.dist_dir = None + self.distinfo_dir = None + self.egginfo_dir = None + self.root_is_pure = None + self.skip_build = None + self.relative = False + self.owner = None + self.group = None + self.universal = False + self.python_tag = 'py' + get_impl_ver()[0] + self.plat_name_supplied = False + + def finalize_options(self): + if self.bdist_dir is None: + bdist_base = self.get_finalized_command('bdist').bdist_base + self.bdist_dir = os.path.join(bdist_base, 'wheel') + + self.data_dir = self.wheel_dist_name + '.data' + self.plat_name_supplied = self.plat_name is not None + + need_options = ('dist_dir', 'plat_name', 'skip_build') + + self.set_undefined_options('bdist', + *zip(need_options, need_options)) + + self.root_is_pure = not (self.distribution.has_ext_modules() + or self.distribution.has_c_libraries()) + + # Support legacy [wheel] section for setting universal + wheel = self.distribution.get_option_dict('wheel') + if 'universal' in wheel: + # please don't define this in your global configs + val = wheel['universal'][1].strip() + if val.lower() in ('1', 'true', 'yes'): + self.universal = True + + @property + def wheel_dist_name(self): + """Return distribution full name with - replaced with _""" + return '-'.join((safer_name(self.distribution.get_name()), + safer_version(self.distribution.get_version()))) + + def get_tag(self): + # bdist sets self.plat_name if unset, we should only use it for purepy + # wheels if the user supplied it. + if self.plat_name_supplied: + plat_name = self.plat_name + elif self.root_is_pure: + plat_name = 'any' + else: + plat_name = self.plat_name or get_platform() + if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize == 2147483647: + plat_name = 'linux_i686' + plat_name = plat_name.replace('-', '_').replace('.', '_') + + + if self.root_is_pure: + if self.universal: + impl = 'py2.py3' + else: + impl = self.python_tag + tag = (impl, 'none', plat_name) + else: + impl_name = get_abbr_impl() + impl_ver = get_impl_ver() + # PEP 3149 + abi_tag = str(get_abi_tag()).lower() + tag = (impl_name + impl_ver, abi_tag, plat_name) + supported_tags = pep425tags.get_supported( + supplied_platform=plat_name if self.plat_name_supplied else None) + # XXX switch to this alternate implementation for non-pure: + assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0]) + return tag + + def get_archive_basename(self): + """Return archive name without extension""" + + impl_tag, abi_tag, plat_tag = self.get_tag() + + archive_basename = "%s-%s-%s-%s" % ( + self.wheel_dist_name, + impl_tag, + abi_tag, + plat_tag) + return archive_basename + + def run(self): + build_scripts = self.reinitialize_command('build_scripts') + build_scripts.executable = 'python' + + if not self.skip_build: + self.run_command('build') + + install = self.reinitialize_command('install', + reinit_subcommands=True) + install.root = self.bdist_dir + install.compile = False + install.skip_build = self.skip_build + install.warn_dir = False + + # A wheel without setuptools scripts is more cross-platform. + # Use the (undocumented) `no_ep` option to setuptools' + # install_scripts command to avoid creating entry point scripts. + install_scripts = self.reinitialize_command('install_scripts') + install_scripts.no_ep = True + + # Use a custom scheme for the archive, because we have to decide + # at installation time which scheme to use. + for key in ('headers', 'scripts', 'data', 'purelib', 'platlib'): + setattr(install, + 'install_' + key, + os.path.join(self.data_dir, key)) + + basedir_observed = '' + + if os.name == 'nt': + # win32 barfs if any of these are ''; could be '.'? + # (distutils.command.install:change_roots bug) + basedir_observed = os.path.normpath(os.path.join(self.data_dir, '..')) + self.install_libbase = self.install_lib = basedir_observed + + setattr(install, + 'install_purelib' if self.root_is_pure else 'install_platlib', + basedir_observed) + + logger.info("installing to %s", self.bdist_dir) + + self.run_command('install') + + archive_basename = self.get_archive_basename() + + pseudoinstall_root = os.path.join(self.dist_dir, archive_basename) + if not self.relative: + archive_root = self.bdist_dir + else: + archive_root = os.path.join( + self.bdist_dir, + self._ensure_relative(install.install_base)) + + self.set_undefined_options( + 'install_egg_info', ('target', 'egginfo_dir')) + self.distinfo_dir = os.path.join(self.bdist_dir, + '%s.dist-info' % self.wheel_dist_name) + self.egg2dist(self.egginfo_dir, + self.distinfo_dir) + + self.write_wheelfile(self.distinfo_dir) + + self.write_record(self.bdist_dir, self.distinfo_dir) + + # Make the archive + if not os.path.exists(self.dist_dir): + os.makedirs(self.dist_dir) + wheel_name = archive_wheelfile(pseudoinstall_root, archive_root) + + # Sign the archive + if 'WHEEL_TOOL' in os.environ: + subprocess.call([os.environ['WHEEL_TOOL'], 'sign', wheel_name]) + + # Add to 'Distribution.dist_files' so that the "upload" command works + getattr(self.distribution, 'dist_files', []).append( + ('bdist_wheel', get_python_version(), wheel_name)) + + if not self.keep_temp: + if self.dry_run: + logger.info('removing %s', self.bdist_dir) + else: + rmtree(self.bdist_dir) + + def write_wheelfile(self, wheelfile_base, generator='bdist_wheel (' + wheel_version + ')'): + from email.message import Message + msg = Message() + msg['Wheel-Version'] = '1.0' # of the spec + msg['Generator'] = generator + msg['Root-Is-Purelib'] = str(self.root_is_pure).lower() + + # Doesn't work for bdist_wininst + impl_tag, abi_tag, plat_tag = self.get_tag() + for impl in impl_tag.split('.'): + for abi in abi_tag.split('.'): + for plat in plat_tag.split('.'): + msg['Tag'] = '-'.join((impl, abi, plat)) + + wheelfile_path = os.path.join(wheelfile_base, 'WHEEL') + logger.info('creating %s', wheelfile_path) + with open(wheelfile_path, 'w') as f: + Generator(f, maxheaderlen=0).flatten(msg) + + def _ensure_relative(self, path): + # copied from dir_util, deleted + drive, path = os.path.splitdrive(path) + if path[0:1] == os.sep: + path = drive + path[1:] + return path + + def _pkginfo_to_metadata(self, egg_info_path, pkginfo_path): + return metadata.pkginfo_to_metadata(egg_info_path, pkginfo_path) + + def license_file(self): + """Return license filename from a license-file key in setup.cfg, or None.""" + metadata = self.distribution.get_option_dict('metadata') + if not 'license_file' in metadata: + return None + return metadata['license_file'][1] + + def setupcfg_requirements(self): + """Generate requirements from setup.cfg as + ('Requires-Dist', 'requirement; qualifier') tuples. From a metadata + section in setup.cfg: + + [metadata] + provides-extra = extra1 + extra2 + requires-dist = requirement; qualifier + another; qualifier2 + unqualified + + Yields + + ('Provides-Extra', 'extra1'), + ('Provides-Extra', 'extra2'), + ('Requires-Dist', 'requirement; qualifier'), + ('Requires-Dist', 'another; qualifier2'), + ('Requires-Dist', 'unqualified') + """ + metadata = self.distribution.get_option_dict('metadata') + + # our .ini parser folds - to _ in key names: + for key, title in (('provides_extra', 'Provides-Extra'), + ('requires_dist', 'Requires-Dist')): + if not key in metadata: + continue + field = metadata[key] + for line in field[1].splitlines(): + line = line.strip() + if not line: + continue + yield (title, line) + + def add_requirements(self, metadata_path): + """Add additional requirements from setup.cfg to file metadata_path""" + additional = list(self.setupcfg_requirements()) + if not additional: return + pkg_info = read_pkg_info(metadata_path) + if 'Provides-Extra' in pkg_info or 'Requires-Dist' in pkg_info: + warnings.warn('setup.cfg requirements overwrite values from setup.py') + del pkg_info['Provides-Extra'] + del pkg_info['Requires-Dist'] + for k, v in additional: + pkg_info[k] = v + write_pkg_info(metadata_path, pkg_info) + + def egg2dist(self, egginfo_path, distinfo_path): + """Convert an .egg-info directory into a .dist-info directory""" + def adios(p): + """Appropriately delete directory, file or link.""" + if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p): + shutil.rmtree(p) + elif os.path.exists(p): + os.unlink(p) + + adios(distinfo_path) + + if not os.path.exists(egginfo_path): + # There is no egg-info. This is probably because the egg-info + # file/directory is not named matching the distribution name used + # to name the archive file. Check for this case and report + # accordingly. + import glob + pat = os.path.join(os.path.dirname(egginfo_path), '*.egg-info') + possible = glob.glob(pat) + err = "Egg metadata expected at %s but not found" % (egginfo_path,) + if possible: + alt = os.path.basename(possible[0]) + err += " (%s found - possible misnamed archive file?)" % (alt,) + + raise ValueError(err) + + if os.path.isfile(egginfo_path): + # .egg-info is a single file + pkginfo_path = egginfo_path + pkg_info = self._pkginfo_to_metadata(egginfo_path, egginfo_path) + os.mkdir(distinfo_path) + else: + # .egg-info is a directory + pkginfo_path = os.path.join(egginfo_path, 'PKG-INFO') + pkg_info = self._pkginfo_to_metadata(egginfo_path, pkginfo_path) + + # ignore common egg metadata that is useless to wheel + shutil.copytree(egginfo_path, distinfo_path, + ignore=lambda x, y: set(('PKG-INFO', + 'requires.txt', + 'SOURCES.txt', + 'not-zip-safe',))) + + # delete dependency_links if it is only whitespace + dependency_links_path = os.path.join(distinfo_path, 'dependency_links.txt') + with open(dependency_links_path, 'r') as dependency_links_file: + dependency_links = dependency_links_file.read().strip() + if not dependency_links: + adios(dependency_links_path) + + write_pkg_info(os.path.join(distinfo_path, 'METADATA'), pkg_info) + + # XXX deprecated. Still useful for current distribute/setuptools. + metadata_path = os.path.join(distinfo_path, 'METADATA') + self.add_requirements(metadata_path) + + # XXX intentionally a different path than the PEP. + metadata_json_path = os.path.join(distinfo_path, 'metadata.json') + pymeta = pkginfo_to_dict(metadata_path, + distribution=self.distribution) + + if 'description' in pymeta: + description_filename = 'DESCRIPTION.rst' + description_text = pymeta.pop('description') + description_path = os.path.join(distinfo_path, + description_filename) + with open(description_path, "wb") as description_file: + description_file.write(description_text.encode('utf-8')) + pymeta['extensions']['python.details']['document_names']['description'] = description_filename + + # XXX heuristically copy any LICENSE/LICENSE.txt? + license = self.license_file() + if license: + license_filename = 'LICENSE.txt' + shutil.copy(license, os.path.join(self.distinfo_dir, license_filename)) + pymeta['extensions']['python.details']['document_names']['license'] = license_filename + + with open(metadata_json_path, "w") as metadata_json: + json.dump(pymeta, metadata_json, sort_keys=True) + + adios(egginfo_path) + + def write_record(self, bdist_dir, distinfo_dir): + from wheel.util import urlsafe_b64encode + + record_path = os.path.join(distinfo_dir, 'RECORD') + record_relpath = os.path.relpath(record_path, bdist_dir) + + def walk(): + for dir, dirs, files in os.walk(bdist_dir): + dirs.sort() + for f in sorted(files): + yield os.path.join(dir, f) + + def skip(path): + """Wheel hashes every possible file.""" + return (path == record_relpath) + + with open_for_csv(record_path, 'w+') as record_file: + writer = csv.writer(record_file) + for path in walk(): + relpath = os.path.relpath(path, bdist_dir) + if skip(relpath): + hash = '' + size = '' + else: + with open(path, 'rb') as f: + data = f.read() + digest = hashlib.sha256(data).digest() + hash = 'sha256=' + native(urlsafe_b64encode(digest)) + size = len(data) + record_path = os.path.relpath( + path, bdist_dir).replace(os.path.sep, '/') + writer.writerow((record_path, hash, size)) + + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +from distutils import log as logger +import os.path + +#from wheel.bdist_wheel import bdist_wheel +class azure_bdist_wheel(bdist_wheel): + + description = "Create an Azure wheel distribution" + + user_options = bdist_wheel.user_options + \ + [('azure-namespace-package=', None, + "Name of the deepest nspkg used")] + + def initialize_options(self): + bdist_wheel.initialize_options(self) + self.azure_namespace_package = None + + def finalize_options(self): + bdist_wheel.finalize_options(self) + if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): + raise ValueError("azure_namespace_package must finish by -nspkg") + + def run(self): + if not self.distribution.install_requires: + self.distribution.install_requires = [] + self.distribution.install_requires.append( + "{}>=2.0.0".format(self.azure_namespace_package)) + bdist_wheel.run(self) + + def write_record(self, bdist_dir, distinfo_dir): + if self.azure_namespace_package: + # Split and remove last part, assuming it's "nspkg" + subparts = self.azure_namespace_package.split('-')[0:-1] + folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] + for azure_sub_package in folder_with_init: + init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') + if os.path.isfile(init_file): + logger.info("manually remove {} while building the wheel".format(init_file)) + os.remove(init_file) + else: + raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) + bdist_wheel.write_record(self, bdist_dir, distinfo_dir) +cmdclass = { + 'bdist_wheel': azure_bdist_wheel, +} diff --git a/azure-mgmt-iothubprovisioningservices/setup.cfg b/azure-mgmt-iothubprovisioningservices/setup.cfg new file mode 100644 index 000000000000..856f4164982c --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/setup.cfg @@ -0,0 +1,3 @@ +[bdist_wheel] +universal=1 +azure-namespace-package=azure-mgmt-nspkg \ No newline at end of file diff --git a/azure-mgmt-iothubprovisioningservices/setup.py b/azure-mgmt-iothubprovisioningservices/setup.py new file mode 100644 index 000000000000..7716e3644cd0 --- /dev/null +++ b/azure-mgmt-iothubprovisioningservices/setup.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + cmdclass = {} + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-iothubprovisioningservices" +PACKAGE_PPRINT_NAME = "IoTHub Provisioning Services" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=["tests"]), + install_requires=[ + 'msrestazure~=0.4.11', + 'azure-common~=1.1', + ], + cmdclass=cmdclass +) diff --git a/package_service_mapping.json b/package_service_mapping.json index 7c9f255b4c47..103afc9fc4c0 100644 --- a/package_service_mapping.json +++ b/package_service_mapping.json @@ -185,6 +185,13 @@ ], "service_name": "IoT" }, + "azure-mgmt-iothubprovisioningservices": { + "category": "Management", + "namespaces": [ + "azure.mgmt.iothubprovisioningservices" + ], + "service_name": "IoT" + }, "azure-mgmt-keyvault": { "category ": "Management", "namespaces": [ @@ -403,4 +410,4 @@ "azure-servicemanagement-legacy": { "service_name": "Other" } -} +} \ No newline at end of file diff --git a/swagger_to_sdk_config.json b/swagger_to_sdk_config.json index 4db4947bad8c..6f03a91235b6 100644 --- a/swagger_to_sdk_config.json +++ b/swagger_to_sdk_config.json @@ -211,6 +211,10 @@ "build_dir": "azure-mgmt-powerbiembedded", "markdown": "specification/powerbiembedded/resource-manager/readme.md" }, + "provisioningservices.mgmt": { + "build_dir": "azure-mgmt-iothubprovisioningservices", + "markdown": "specification/provisioningservices/resource-manager/readme.md", + }, "rdbms.mysql": { "build_dir": "azure-mgmt-rdbms/azure/mgmt/rdbms/mysql", "markdown": "specification/mysql/resource-manager/readme.md"