diff --git a/sdk/iothub/azure-mgmt-iotcentral/CHANGELOG.md b/sdk/iothub/azure-mgmt-iotcentral/CHANGELOG.md new file mode 100644 index 000000000000..1c4a3736f0ef --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/CHANGELOG.md @@ -0,0 +1,115 @@ +# Release History + +## 9.0.0b1 (2021-05-13) + +This is beta preview version. + +This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming). + +**General breaking changes** + +- Credential system has been completly revamped: + + - `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/ + - `credentials` parameter has been renamed `credential` + +- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of + supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) +- You can't import a `version` module anymore, use `__version__` instead +- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`. +- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed). +- Most of the operation kwarg have changed. Some of the most noticeable: + + - `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user + - For a complete set of + supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) + +**General new features** + +- Type annotations support using `typing`. SDKs are mypy ready. +- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client. +- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core-tracing-opentelemetry) for an overview. + +## 4.1.0 (2021-02-19) + +**Features** + + - Model AppTemplate has a new parameter industry + - Model AppTemplate has a new parameter locations + - Model Operation has a new parameter properties + - Model Operation has a new parameter origin + +## 4.0.0 (2021-01-05) + +**Features** + + - Model AppTemplate has a new parameter name + +**Breaking changes** + + - Model AppTemplate no longer has parameter app_template_name + +## 3.1.0 (2020-06-30) + +**Features** + + - Model AppPatch has a new parameter sku + +## 3.0.0 (2020-03-09) + +**Breaking changes** + +- Removed operation AppsOperations.list_templates + +## 2.0.0 (2019-12-25) + +**Features** + + - Added operation AppsOperations.list_templates + +**General Breaking Changes** + +This version uses a next-generation code generator that might introduce +breaking changes if from some import. In summary, some modules were +incorrectly visible/importable and have been renamed. This fixed several +issues caused by usage of classes that were not supposed to be used in +the first place. IoTCentralClient cannot be imported from +azure.mgmt.iotcentreal.iot_central_client anymore (import from +azure.mgmt.iotcentreal works like before) IoTCentralClientConfiguration +import has been moved from azure.mgmt.iotcentreal.iot_central_client +to azure.mgmt.iotcentreal A model MyClass from a "models" sub-module +cannot be imported anymore using azure.mgmt.iotcentreal.models.my_class +(import from azure.mgmt.iotcentreal.models works like before) An +operation class MyClassOperations from an operations sub-module cannot +be imported anymore using +azure.mgmt.iotcentreal.operations.my_class_operations (import from +azure.mgmt.iotcentreal.operations works like before) Last but not least, +HTTP connection pooling is now enabled by default. You should always use +a client as a context manager, or call close(), or use no more than one +client per process. + +## 1.0.0 (2018-10-26) + +**Features** + + - Model OperationInputs has a new parameter type + - Model ErrorDetails has a new parameter details + - Added operation AppsOperations.check_subdomain_availability + +**Breaking changes** + + - Operation AppsOperations.check_name_availability has a new + signature + +**Note** + + - azure-mgmt-nspkg is not installed anymore on Python 3 (PEP420-based + namespace package) + +## 0.2.0 (2018-08-07) + + - Replace API version by 2018-09-01 + +## 0.1.0 (2018-07-16) + + - Initial Release with support for 2017-07-01-privatepreview \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iotcentral/MANIFEST.in b/sdk/iothub/azure-mgmt-iotcentral/MANIFEST.in new file mode 100644 index 000000000000..3a9b6517412b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/sdk/iothub/azure-mgmt-iotcentral/README.md b/sdk/iothub/azure-mgmt-iotcentral/README.md new file mode 100644 index 000000000000..ba04f39a31f3 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Iotcentral Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Iotcentral Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-iotcentral%2FREADME.png) diff --git a/sdk/iothub/azure-mgmt-iotcentral/_meta.json b/sdk/iothub/azure-mgmt-iotcentral/_meta.json new file mode 100644 index 000000000000..b36b0cb959aa --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "3.4.2", + "use": "@autorest/python@5.6.6", + "commit": "15d7abacf7b4f7317ef96f7e8300a7b51e315e7b", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/iotcentral/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.4.2", + "readme": "specification/iotcentral/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/__init__.py new file mode 100644 index 000000000000..d968b0ec90f6 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._iot_central_client import IotCentralClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['IotCentralClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_configuration.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_configuration.py new file mode 100644 index 000000000000..cfc92edae559 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_configuration.py @@ -0,0 +1,71 @@ +# 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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class IotCentralClientConfiguration(Configuration): + """Configuration for IotCentralClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(IotCentralClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-09-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-iotcentral/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_iot_central_client.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_iot_central_client.py new file mode 100644 index 000000000000..8380d8a3b3e3 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_iot_central_client.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import IotCentralClientConfiguration +from .operations import AppsOperations +from .operations import Operations +from . import models + + +class IotCentralClient(object): + """Use this API to manage IoT Central Applications in your Azure subscription. + + :ivar apps: AppsOperations operations + :vartype apps: azure.mgmt.iotcentral.operations.AppsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iotcentral.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = IotCentralClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.apps = AppsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> IotCentralClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_metadata.json b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_metadata.json new file mode 100644 index 000000000000..4beed9e62cf3 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2018-09-01", + "total_api_version_list": ["2018-09-01"], + "client": { + "name": "IotCentralClient", + "filename": "_iot_central_client", + "description": "Use this API to manage IoT Central Applications in your Azure subscription.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotCentralClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotCentralClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The subscription identifier.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "apps": "AppsOperations", + "operations": "Operations" + } +} \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_version.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_version.py new file mode 100644 index 000000000000..6dddc002d43d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "9.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/__init__.py new file mode 100644 index 000000000000..3ed5a24faaf1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/__init__.py @@ -0,0 +1,10 @@ +# 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_central_client import IotCentralClient +__all__ = ['IotCentralClient'] diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/_configuration.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/_configuration.py new file mode 100644 index 000000000000..1c9e1d05b287 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotCentralClientConfiguration(Configuration): + """Configuration for IotCentralClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(IotCentralClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-09-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-iotcentral/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/_iot_central_client.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/_iot_central_client.py new file mode 100644 index 000000000000..94462f7539f2 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/_iot_central_client.py @@ -0,0 +1,87 @@ +# 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 typing import Any, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import IotCentralClientConfiguration +from .operations import AppsOperations +from .operations import Operations +from .. import models + + +class IotCentralClient(object): + """Use this API to manage IoT Central Applications in your Azure subscription. + + :ivar apps: AppsOperations operations + :vartype apps: azure.mgmt.iotcentral.aio.operations.AppsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iotcentral.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = IotCentralClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.apps = AppsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "IotCentralClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/__init__.py new file mode 100644 index 000000000000..adc221bcf091 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._apps_operations import AppsOperations +from ._operations import Operations + +__all__ = [ + 'AppsOperations', + 'Operations', +] diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/_apps_operations.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/_apps_operations.py new file mode 100644 index 000000000000..900072f121b1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/_apps_operations.py @@ -0,0 +1,792 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AppsOperations: + """AppsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.iotcentral.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + resource_name: str, + **kwargs + ) -> "_models.App": + """Get the metadata of an IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: App, or the result of cls(response) + :rtype: ~azure.mgmt.iotcentral.models.App + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.App"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + app: "_models.App", + **kwargs + ) -> Optional["_models.App"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.App"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(app, 'App') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('App', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + app: "_models.App", + **kwargs + ) -> AsyncLROPoller["_models.App"]: + """Create or update the metadata of an IoT Central application. The usual pattern to modify a + property is to retrieve the IoT Central application metadata and security metadata, and then + combine them with the modified values in a new body to update the IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :param app: The IoT Central application metadata and security metadata. + :type app: ~azure.mgmt.iotcentral.models.App + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either App or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iotcentral.models.App] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.App"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + app=app, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + app_patch: "_models.AppPatch", + **kwargs + ) -> Optional["_models.App"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.App"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(app_patch, 'AppPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + app_patch: "_models.AppPatch", + **kwargs + ) -> AsyncLROPoller["_models.App"]: + """Update the metadata of an IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :param app_patch: The IoT Central application metadata and security metadata. + :type app_patch: ~azure.mgmt.iotcentral.models.AppPatch + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either App or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iotcentral.models.App] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.App"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + app_patch=app_patch, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + resource_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Delete an IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["_models.AppListResult"]: + """Get all IoT Central Applications in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iotcentral.models.AppListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AppListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/iotApps'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_models.AppListResult"]: + """Get all the IoT Central Applications in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iotcentral.models.AppListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AppListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps'} # type: ignore + + async def check_name_availability( + self, + operation_inputs: "_models.OperationInputs", + **kwargs + ) -> "_models.AppAvailabilityInfo": + """Check if an IoT Central application name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT Central application to check. + :type operation_inputs: ~azure.mgmt.iotcentral.models.OperationInputs + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppAvailabilityInfo, or the result of cls(response) + :rtype: ~azure.mgmt.iotcentral.models.AppAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(operation_inputs, 'OperationInputs') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AppAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/checkNameAvailability'} # type: ignore + + async def check_subdomain_availability( + self, + operation_inputs: "_models.OperationInputs", + **kwargs + ) -> "_models.AppAvailabilityInfo": + """Check if an IoT Central application subdomain is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the + subdomain of the IoT Central application to check. + :type operation_inputs: ~azure.mgmt.iotcentral.models.OperationInputs + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppAvailabilityInfo, or the result of cls(response) + :rtype: ~azure.mgmt.iotcentral.models.AppAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_subdomain_availability.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(operation_inputs, 'OperationInputs') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AppAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_subdomain_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/checkSubdomainAvailability'} # type: ignore + + def list_templates( + self, + **kwargs + ) -> AsyncIterable["_models.AppTemplatesResult"]: + """Get all available application templates. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppTemplatesResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iotcentral.models.AppTemplatesResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppTemplatesResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_templates.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AppTemplatesResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_templates.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/appTemplates'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/_operations.py new file mode 100644 index 000000000000..cb72d188d89c --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/aio/operations/_operations.py @@ -0,0 +1,104 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.iotcentral.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists all of the available IoT Central application REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iotcentral.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.IoTCentral/operations'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/__init__.py new file mode 100644 index 000000000000..46894127691b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import App + from ._models_py3 import AppAvailabilityInfo + from ._models_py3 import AppListResult + from ._models_py3 import AppPatch + from ._models_py3 import AppSkuInfo + from ._models_py3 import AppTemplate + from ._models_py3 import AppTemplateLocations + from ._models_py3 import AppTemplatesResult + from ._models_py3 import CloudErrorBody + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationInputs + from ._models_py3 import OperationListResult + from ._models_py3 import Resource +except (SyntaxError, ImportError): + from ._models import App # type: ignore + from ._models import AppAvailabilityInfo # type: ignore + from ._models import AppListResult # type: ignore + from ._models import AppPatch # type: ignore + from ._models import AppSkuInfo # type: ignore + from ._models import AppTemplate # type: ignore + from ._models import AppTemplateLocations # type: ignore + from ._models import AppTemplatesResult # type: ignore + from ._models import CloudErrorBody # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationInputs # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import Resource # type: ignore + +from ._iot_central_client_enums import ( + AppSku, +) + +__all__ = [ + 'App', + 'AppAvailabilityInfo', + 'AppListResult', + 'AppPatch', + 'AppSkuInfo', + 'AppTemplate', + 'AppTemplateLocations', + 'AppTemplatesResult', + 'CloudErrorBody', + 'Operation', + 'OperationDisplay', + 'OperationInputs', + 'OperationListResult', + 'Resource', + 'AppSku', +] diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_iot_central_client_enums.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_iot_central_client_enums.py new file mode 100644 index 000000000000..6a99e3a1cbb1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_iot_central_client_enums.py @@ -0,0 +1,37 @@ +# 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, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class AppSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The name of the SKU. + """ + + F1 = "F1" + S1 = "S1" + ST0 = "ST0" + ST1 = "ST1" + ST2 = "ST2" diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_models.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_models.py new file mode 100644 index 000000000000..d1ca34ecab30 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_models.py @@ -0,0 +1,546 @@ +# 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 msrest.serialization + + +class Resource(msrest.serialization.Model): + """The common properties of an ARM resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The ARM resource identifier. + :vartype id: str + :ivar name: The ARM resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :param location: Required. The resource location. + :type location: str + :param tags: A set of 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,99}[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, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = kwargs['location'] + self.tags = kwargs.get('tags', None) + + +class App(Resource): + """The IoT Central application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The ARM resource identifier. + :vartype id: str + :ivar name: The ARM resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :param location: Required. The resource location. + :type location: str + :param tags: A set of tags. The resource tags. + :type tags: dict[str, str] + :param sku: Required. A valid instance SKU. + :type sku: ~azure.mgmt.iotcentral.models.AppSkuInfo + :ivar application_id: The ID of the application. + :vartype application_id: str + :param display_name: The display name of the application. + :type display_name: str + :param subdomain: The subdomain of the application. + :type subdomain: str + :param template: The ID of the application template, which is a blueprint that defines the + characteristics and behaviors of an application. Optional; if not specified, defaults to a + blank blueprint and allows the application to be defined from scratch. + :type template: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,99}[a-zA-Z0-9]$'}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'sku': {'required': True}, + 'application_id': {'readonly': 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}'}, + 'sku': {'key': 'sku', 'type': 'AppSkuInfo'}, + 'application_id': {'key': 'properties.applicationId', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'subdomain': {'key': 'properties.subdomain', 'type': 'str'}, + 'template': {'key': 'properties.template', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(App, self).__init__(**kwargs) + self.sku = kwargs['sku'] + self.application_id = None + self.display_name = kwargs.get('display_name', None) + self.subdomain = kwargs.get('subdomain', None) + self.template = kwargs.get('template', None) + + +class AppAvailabilityInfo(msrest.serialization.Model): + """The properties indicating whether a given IoT Central application name or subdomain is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. + :vartype reason: str + :ivar message: The detailed reason message. + :vartype message: str + """ + + _validation = { + 'name_available': {'readonly': True}, + 'reason': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppAvailabilityInfo, self).__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = None + + +class AppListResult(msrest.serialization.Model): + """A list of IoT Central Applications with a next link. + + :param next_link: The link used to get the next page of IoT Central Applications. + :type next_link: str + :param value: A list of IoT Central Applications. + :type value: list[~azure.mgmt.iotcentral.models.App] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[App]'}, + } + + def __init__( + self, + **kwargs + ): + super(AppListResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class AppPatch(msrest.serialization.Model): + """The description of the IoT Central application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param tags: A set of tags. Instance tags. + :type tags: dict[str, str] + :param sku: A valid instance SKU. + :type sku: ~azure.mgmt.iotcentral.models.AppSkuInfo + :ivar application_id: The ID of the application. + :vartype application_id: str + :param display_name: The display name of the application. + :type display_name: str + :param subdomain: The subdomain of the application. + :type subdomain: str + :param template: The ID of the application template, which is a blueprint that defines the + characteristics and behaviors of an application. Optional; if not specified, defaults to a + blank blueprint and allows the application to be defined from scratch. + :type template: str + """ + + _validation = { + 'application_id': {'readonly': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'AppSkuInfo'}, + 'application_id': {'key': 'properties.applicationId', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'subdomain': {'key': 'properties.subdomain', 'type': 'str'}, + 'template': {'key': 'properties.template', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppPatch, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.sku = kwargs.get('sku', None) + self.application_id = None + self.display_name = kwargs.get('display_name', None) + self.subdomain = kwargs.get('subdomain', None) + self.template = kwargs.get('template', None) + + +class AppSkuInfo(msrest.serialization.Model): + """Information about the SKU of the IoT Central application. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "ST0", "ST1", + "ST2". + :type name: str or ~azure.mgmt.iotcentral.models.AppSku + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppSkuInfo, self).__init__(**kwargs) + self.name = kwargs['name'] + + +class AppTemplate(msrest.serialization.Model): + """IoT Central Application Template. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar manifest_id: The ID of the template. + :vartype manifest_id: str + :ivar manifest_version: The version of the template. + :vartype manifest_version: str + :ivar name: The name of the template. + :vartype name: str + :ivar title: The title of the template. + :vartype title: str + :ivar order: The order of the template in the templates list. + :vartype order: float + :ivar description: The description of the template. + :vartype description: str + :ivar industry: The industry of the template. + :vartype industry: str + :ivar locations: A list of locations that support the template. + :vartype locations: list[~azure.mgmt.iotcentral.models.AppTemplateLocations] + """ + + _validation = { + 'manifest_id': {'readonly': True}, + 'manifest_version': {'readonly': True}, + 'name': {'readonly': True}, + 'title': {'readonly': True}, + 'order': {'readonly': True}, + 'description': {'readonly': True}, + 'industry': {'readonly': True}, + 'locations': {'readonly': True}, + } + + _attribute_map = { + 'manifest_id': {'key': 'manifestId', 'type': 'str'}, + 'manifest_version': {'key': 'manifestVersion', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'order': {'key': 'order', 'type': 'float'}, + 'description': {'key': 'description', 'type': 'str'}, + 'industry': {'key': 'industry', 'type': 'str'}, + 'locations': {'key': 'locations', 'type': '[AppTemplateLocations]'}, + } + + def __init__( + self, + **kwargs + ): + super(AppTemplate, self).__init__(**kwargs) + self.manifest_id = None + self.manifest_version = None + self.name = None + self.title = None + self.order = None + self.description = None + self.industry = None + self.locations = None + + +class AppTemplateLocations(msrest.serialization.Model): + """IoT Central Application Template Locations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the location. + :vartype id: str + :ivar display_name: The display name of the location. + :vartype display_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppTemplateLocations, self).__init__(**kwargs) + self.id = None + self.display_name = None + + +class AppTemplatesResult(msrest.serialization.Model): + """A list of IoT Central Application Templates with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param next_link: The link used to get the next page of IoT Central application templates. + :type next_link: str + :ivar value: A list of IoT Central Application Templates. + :vartype value: list[~azure.mgmt.iotcentral.models.AppTemplate] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[AppTemplate]'}, + } + + def __init__( + self, + **kwargs + ): + super(AppTemplatesResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = None + + +class CloudErrorBody(msrest.serialization.Model): + """Details of error response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.iotcentral.models.CloudErrorBody] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = kwargs.get('details', None) + + +class Operation(msrest.serialization.Model): + """IoT Central 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.iotcentral.models.OperationDisplay + :ivar origin: The intended executor of the operation. + :vartype origin: str + :ivar properties: Additional descriptions for the operation. + :vartype properties: str + """ + + _validation = { + 'name': {'readonly': True}, + 'origin': {'readonly': True}, + 'properties': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = kwargs.get('display', None) + self.origin = None + self.properties = None + + +class OperationDisplay(msrest.serialization.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 IoT Central. + :vartype provider: str + :ivar resource: Resource Type: IoT Central. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Friendly description for the operation,. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationInputs(msrest.serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the IoT Central application instance to check. + :type name: str + :param type: The type of the IoT Central resource to query. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationInputs, self).__init__(**kwargs) + self.name = kwargs['name'] + self.type = kwargs.get('type', "IoTApps") + + +class OperationListResult(msrest.serialization.Model): + """A list of IoT Central operations. It contains a list of operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param next_link: The link used to get the next page of IoT Central description objects. + :type next_link: str + :ivar value: A list of operations supported by the Microsoft.IoTCentral resource provider. + :vartype value: list[~azure.mgmt.iotcentral.models.Operation] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Operation]'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = None diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_models_py3.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_models_py3.py new file mode 100644 index 000000000000..cb80f7e3165e --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/models/_models_py3.py @@ -0,0 +1,582 @@ +# 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 typing import Dict, List, Optional, Union + +import msrest.serialization + +from ._iot_central_client_enums import * + + +class Resource(msrest.serialization.Model): + """The common properties of an ARM resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The ARM resource identifier. + :vartype id: str + :ivar name: The ARM resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :param location: Required. The resource location. + :type location: str + :param tags: A set of 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,99}[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: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class App(Resource): + """The IoT Central application. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The ARM resource identifier. + :vartype id: str + :ivar name: The ARM resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :param location: Required. The resource location. + :type location: str + :param tags: A set of tags. The resource tags. + :type tags: dict[str, str] + :param sku: Required. A valid instance SKU. + :type sku: ~azure.mgmt.iotcentral.models.AppSkuInfo + :ivar application_id: The ID of the application. + :vartype application_id: str + :param display_name: The display name of the application. + :type display_name: str + :param subdomain: The subdomain of the application. + :type subdomain: str + :param template: The ID of the application template, which is a blueprint that defines the + characteristics and behaviors of an application. Optional; if not specified, defaults to a + blank blueprint and allows the application to be defined from scratch. + :type template: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,99}[a-zA-Z0-9]$'}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'sku': {'required': True}, + 'application_id': {'readonly': 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}'}, + 'sku': {'key': 'sku', 'type': 'AppSkuInfo'}, + 'application_id': {'key': 'properties.applicationId', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'subdomain': {'key': 'properties.subdomain', 'type': 'str'}, + 'template': {'key': 'properties.template', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + sku: "AppSkuInfo", + tags: Optional[Dict[str, str]] = None, + display_name: Optional[str] = None, + subdomain: Optional[str] = None, + template: Optional[str] = None, + **kwargs + ): + super(App, self).__init__(location=location, tags=tags, **kwargs) + self.sku = sku + self.application_id = None + self.display_name = display_name + self.subdomain = subdomain + self.template = template + + +class AppAvailabilityInfo(msrest.serialization.Model): + """The properties indicating whether a given IoT Central application name or subdomain is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. + :vartype reason: str + :ivar message: The detailed reason message. + :vartype message: str + """ + + _validation = { + 'name_available': {'readonly': True}, + 'reason': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppAvailabilityInfo, self).__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = None + + +class AppListResult(msrest.serialization.Model): + """A list of IoT Central Applications with a next link. + + :param next_link: The link used to get the next page of IoT Central Applications. + :type next_link: str + :param value: A list of IoT Central Applications. + :type value: list[~azure.mgmt.iotcentral.models.App] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[App]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["App"]] = None, + **kwargs + ): + super(AppListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class AppPatch(msrest.serialization.Model): + """The description of the IoT Central application. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param tags: A set of tags. Instance tags. + :type tags: dict[str, str] + :param sku: A valid instance SKU. + :type sku: ~azure.mgmt.iotcentral.models.AppSkuInfo + :ivar application_id: The ID of the application. + :vartype application_id: str + :param display_name: The display name of the application. + :type display_name: str + :param subdomain: The subdomain of the application. + :type subdomain: str + :param template: The ID of the application template, which is a blueprint that defines the + characteristics and behaviors of an application. Optional; if not specified, defaults to a + blank blueprint and allows the application to be defined from scratch. + :type template: str + """ + + _validation = { + 'application_id': {'readonly': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'AppSkuInfo'}, + 'application_id': {'key': 'properties.applicationId', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'subdomain': {'key': 'properties.subdomain', 'type': 'str'}, + 'template': {'key': 'properties.template', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + sku: Optional["AppSkuInfo"] = None, + display_name: Optional[str] = None, + subdomain: Optional[str] = None, + template: Optional[str] = None, + **kwargs + ): + super(AppPatch, self).__init__(**kwargs) + self.tags = tags + self.sku = sku + self.application_id = None + self.display_name = display_name + self.subdomain = subdomain + self.template = template + + +class AppSkuInfo(msrest.serialization.Model): + """Information about the SKU of the IoT Central application. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "ST0", "ST1", + "ST2". + :type name: str or ~azure.mgmt.iotcentral.models.AppSku + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "AppSku"], + **kwargs + ): + super(AppSkuInfo, self).__init__(**kwargs) + self.name = name + + +class AppTemplate(msrest.serialization.Model): + """IoT Central Application Template. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar manifest_id: The ID of the template. + :vartype manifest_id: str + :ivar manifest_version: The version of the template. + :vartype manifest_version: str + :ivar name: The name of the template. + :vartype name: str + :ivar title: The title of the template. + :vartype title: str + :ivar order: The order of the template in the templates list. + :vartype order: float + :ivar description: The description of the template. + :vartype description: str + :ivar industry: The industry of the template. + :vartype industry: str + :ivar locations: A list of locations that support the template. + :vartype locations: list[~azure.mgmt.iotcentral.models.AppTemplateLocations] + """ + + _validation = { + 'manifest_id': {'readonly': True}, + 'manifest_version': {'readonly': True}, + 'name': {'readonly': True}, + 'title': {'readonly': True}, + 'order': {'readonly': True}, + 'description': {'readonly': True}, + 'industry': {'readonly': True}, + 'locations': {'readonly': True}, + } + + _attribute_map = { + 'manifest_id': {'key': 'manifestId', 'type': 'str'}, + 'manifest_version': {'key': 'manifestVersion', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'order': {'key': 'order', 'type': 'float'}, + 'description': {'key': 'description', 'type': 'str'}, + 'industry': {'key': 'industry', 'type': 'str'}, + 'locations': {'key': 'locations', 'type': '[AppTemplateLocations]'}, + } + + def __init__( + self, + **kwargs + ): + super(AppTemplate, self).__init__(**kwargs) + self.manifest_id = None + self.manifest_version = None + self.name = None + self.title = None + self.order = None + self.description = None + self.industry = None + self.locations = None + + +class AppTemplateLocations(msrest.serialization.Model): + """IoT Central Application Template Locations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the location. + :vartype id: str + :ivar display_name: The display name of the location. + :vartype display_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppTemplateLocations, self).__init__(**kwargs) + self.id = None + self.display_name = None + + +class AppTemplatesResult(msrest.serialization.Model): + """A list of IoT Central Application Templates with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param next_link: The link used to get the next page of IoT Central application templates. + :type next_link: str + :ivar value: A list of IoT Central Application Templates. + :vartype value: list[~azure.mgmt.iotcentral.models.AppTemplate] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[AppTemplate]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + **kwargs + ): + super(AppTemplatesResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = None + + +class CloudErrorBody(msrest.serialization.Model): + """Details of error response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.iotcentral.models.CloudErrorBody] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = details + + +class Operation(msrest.serialization.Model): + """IoT Central 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.iotcentral.models.OperationDisplay + :ivar origin: The intended executor of the operation. + :vartype origin: str + :ivar properties: Additional descriptions for the operation. + :vartype properties: str + """ + + _validation = { + 'name': {'readonly': True}, + 'origin': {'readonly': True}, + 'properties': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = display + self.origin = None + self.properties = None + + +class OperationDisplay(msrest.serialization.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 IoT Central. + :vartype provider: str + :ivar resource: Resource Type: IoT Central. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Friendly description for the operation,. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationInputs(msrest.serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the IoT Central application instance to check. + :type name: str + :param type: The type of the IoT Central resource to query. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + type: Optional[str] = "IoTApps", + **kwargs + ): + super(OperationInputs, self).__init__(**kwargs) + self.name = name + self.type = type + + +class OperationListResult(msrest.serialization.Model): + """A list of IoT Central operations. It contains a list of operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param next_link: The link used to get the next page of IoT Central description objects. + :type next_link: str + :ivar value: A list of operations supported by the Microsoft.IoTCentral resource provider. + :vartype value: list[~azure.mgmt.iotcentral.models.Operation] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Operation]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = None diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/__init__.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/__init__.py new file mode 100644 index 000000000000..adc221bcf091 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._apps_operations import AppsOperations +from ._operations import Operations + +__all__ = [ + 'AppsOperations', + 'Operations', +] diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/_apps_operations.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/_apps_operations.py new file mode 100644 index 000000000000..e3f18876efff --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/_apps_operations.py @@ -0,0 +1,808 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AppsOperations(object): + """AppsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.iotcentral.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + resource_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.App" + """Get the metadata of an IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: App, or the result of cls(response) + :rtype: ~azure.mgmt.iotcentral.models.App + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.App"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + resource_name, # type: str + app, # type: "_models.App" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.App"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.App"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(app, 'App') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('App', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_name, # type: str + app, # type: "_models.App" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.App"] + """Create or update the metadata of an IoT Central application. The usual pattern to modify a + property is to retrieve the IoT Central application metadata and security metadata, and then + combine them with the modified values in a new body to update the IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :param app: The IoT Central application metadata and security metadata. + :type app: ~azure.mgmt.iotcentral.models.App + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either App or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iotcentral.models.App] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.App"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + app=app, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def _update_initial( + self, + resource_group_name, # type: str + resource_name, # type: str + app_patch, # type: "_models.AppPatch" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.App"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.App"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(app_patch, 'AppPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_name, # type: str + app_patch, # type: "_models.AppPatch" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.App"] + """Update the metadata of an IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :param app_patch: The IoT Central application metadata and security metadata. + :type app_patch: ~azure.mgmt.iotcentral.models.AppPatch + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either App or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iotcentral.models.App] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.App"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + app_patch=app_patch, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('App', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + resource_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + resource_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete an IoT Central application. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :param resource_name: The ARM resource name of the IoT Central application. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + 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'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps/{resourceName}'} # type: ignore + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AppListResult"] + """Get all IoT Central Applications in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iotcentral.models.AppListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AppListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/iotApps'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AppListResult"] + """Get all the IoT Central Applications in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT Central + application. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iotcentral.models.AppListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AppListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTCentral/iotApps'} # type: ignore + + def check_name_availability( + self, + operation_inputs, # type: "_models.OperationInputs" + **kwargs # type: Any + ): + # type: (...) -> "_models.AppAvailabilityInfo" + """Check if an IoT Central application name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT Central application to check. + :type operation_inputs: ~azure.mgmt.iotcentral.models.OperationInputs + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppAvailabilityInfo, or the result of cls(response) + :rtype: ~azure.mgmt.iotcentral.models.AppAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(operation_inputs, 'OperationInputs') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AppAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/checkNameAvailability'} # type: ignore + + def check_subdomain_availability( + self, + operation_inputs, # type: "_models.OperationInputs" + **kwargs # type: Any + ): + # type: (...) -> "_models.AppAvailabilityInfo" + """Check if an IoT Central application subdomain is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the + subdomain of the IoT Central application to check. + :type operation_inputs: ~azure.mgmt.iotcentral.models.OperationInputs + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppAvailabilityInfo, or the result of cls(response) + :rtype: ~azure.mgmt.iotcentral.models.AppAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_subdomain_availability.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(operation_inputs, 'OperationInputs') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AppAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_subdomain_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/checkSubdomainAvailability'} # type: ignore + + def list_templates( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AppTemplatesResult"] + """Get all available application templates. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AppTemplatesResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iotcentral.models.AppTemplatesResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AppTemplatesResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_templates.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AppTemplatesResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_templates.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/appTemplates'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/_operations.py b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/_operations.py new file mode 100644 index 000000000000..6645b716bef2 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/operations/_operations.py @@ -0,0 +1,109 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.iotcentral.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationListResult"] + """Lists all of the available IoT Central application REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iotcentral.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.IoTCentral/operations'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/py.typed b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/azure/mgmt/iotcentral/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iotcentral/sdk_packaging.toml b/sdk/iothub/azure-mgmt-iotcentral/sdk_packaging.toml new file mode 100644 index 000000000000..5b65a8cc9a97 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-iotcentral" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Iotcentral Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/iothub/azure-mgmt-iotcentral/setup.cfg b/sdk/iothub/azure-mgmt-iotcentral/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/iothub/azure-mgmt-iotcentral/setup.py b/sdk/iothub/azure-mgmt-iotcentral/setup.py new file mode 100644 index 000000000000..8a3d69480daa --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/setup.py @@ -0,0 +1,91 @@ +#!/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 + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-iotcentral" +PACKAGE_PPRINT_NAME = "Iotcentral Management" + +# 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') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else 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.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + 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.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +) diff --git a/shared_requirements.txt b/shared_requirements.txt index ee8b489c5ca8..12ca338940da 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -274,6 +274,7 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-mgmt-storagecache msrest>=0.6.21 #override azure-mgmt-videoanalyzer msrest>=0.6.21 #override azure-mgmt-extendedlocation msrest>=0.6.21 +#override azure-mgmt-iotcentral msrest>=0.6.21 #override azure-mgmt-sql msrest>=0.6.21 #override azure-agrifood-farming azure-core<2.0.0,>=1.8.2 #override azure-agrifood-farming msrest>=0.6.21