From 7033985763c4176e92f07dd8ecc5476f20d7530e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 25 Mar 2022 08:18:21 +0000 Subject: [PATCH] CodeGen from PR 18390 in Azure/azure-rest-api-specs Merge fb9611f3fa471827b4455ffe6b68534ea5339287 into 202149c96d7e5cdd07cdcbc138309142b55321ad --- .../azure-mgmt-windowsiot/CHANGELOG.md | 5 + sdk/windowsiot/azure-mgmt-windowsiot/LICENSE | 21 + .../azure-mgmt-windowsiot/MANIFEST.in | 6 + .../azure-mgmt-windowsiot/README.md | 30 + .../azure-mgmt-windowsiot/_meta.json | 11 + .../azure-mgmt-windowsiot/azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/windowsiot/__init__.py | 18 + .../azure/mgmt/windowsiot/_configuration.py | 68 ++ .../azure/mgmt/windowsiot/_device_services.py | 94 +++ .../azure/mgmt/windowsiot/_metadata.json | 103 +++ .../azure/mgmt/windowsiot/_patch.py | 31 + .../azure/mgmt/windowsiot/_vendor.py | 27 + .../azure/mgmt/windowsiot/_version.py | 9 + .../azure/mgmt/windowsiot/aio/__init__.py | 15 + .../mgmt/windowsiot/aio/_configuration.py | 67 ++ .../mgmt/windowsiot/aio/_device_services.py | 91 +++ .../azure/mgmt/windowsiot/aio/_patch.py | 31 + .../windowsiot/aio/operations/__init__.py | 15 + .../windowsiot/aio/operations/_operations.py | 110 +++ .../aio/operations/_services_operations.py | 494 +++++++++++ .../azure/mgmt/windowsiot/models/__init__.py | 41 + .../models/_device_services_enums.py | 19 + .../mgmt/windowsiot/models/_models_py3.py | 524 ++++++++++++ .../mgmt/windowsiot/operations/__init__.py | 15 + .../mgmt/windowsiot/operations/_operations.py | 135 ++++ .../operations/_services_operations.py | 764 ++++++++++++++++++ .../azure/mgmt/windowsiot/py.typed | 1 + .../azure-mgmt-windowsiot/sdk_packaging.toml | 9 + sdk/windowsiot/azure-mgmt-windowsiot/setup.py | 74 ++ sdk/windowsiot/ci.yml | 33 + 31 files changed, 2863 insertions(+) create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/CHANGELOG.md create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/LICENSE create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/MANIFEST.in create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/README.md create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/_meta.json create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_configuration.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_device_services.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_metadata.json create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_patch.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_vendor.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_version.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_configuration.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_device_services.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_patch.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_operations.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_services_operations.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_device_services_enums.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_models_py3.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/__init__.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_operations.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_services_operations.py create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/py.typed create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/sdk_packaging.toml create mode 100644 sdk/windowsiot/azure-mgmt-windowsiot/setup.py create mode 100644 sdk/windowsiot/ci.yml diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/CHANGELOG.md b/sdk/windowsiot/azure-mgmt-windowsiot/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/LICENSE b/sdk/windowsiot/azure-mgmt-windowsiot/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/MANIFEST.in b/sdk/windowsiot/azure-mgmt-windowsiot/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/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 +include LICENSE diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/README.md b/sdk/windowsiot/azure-mgmt-windowsiot/README.md new file mode 100644 index 000000000000..6d1646e71a62 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# 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 [MyService 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-windowsiot%2FREADME.png) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/_meta.json b/sdk/windowsiot/azure-mgmt-windowsiot/_meta.json new file mode 100644 index 000000000000..9591990cb234 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "9504e15c4484b975abd432727e6ed282fb7fa04b", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/windowsiot/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/windowsiot/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/__init__.py new file mode 100644 index 000000000000..d08098536329 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._device_services import DeviceServices +from ._version import VERSION + +__version__ = VERSION +__all__ = ['DeviceServices'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_configuration.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_configuration.py new file mode 100644 index 000000000000..da7d8042738d --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_configuration.py @@ -0,0 +1,68 @@ +# 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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DeviceServicesConfiguration(Configuration): + """Configuration for DeviceServices. + + 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: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DeviceServicesConfiguration, self).__init__(**kwargs) + 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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-windowsiot/{}'.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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_device_services.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_device_services.py new file mode 100644 index 000000000000..04250a192c45 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_device_services.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 copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import DeviceServicesConfiguration +from .operations import Operations, ServicesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class DeviceServices: + """Use this API to manage the Windows IoT device services in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.windowsiot.operations.Operations + :ivar services: ServicesOperations operations + :vartype services: azure.mgmt.windowsiot.operations.ServicesOperations + :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 base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DeviceServicesConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DeviceServices + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_metadata.json b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_metadata.json new file mode 100644 index 000000000000..ac353bcb53dc --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_metadata.json @@ -0,0 +1,103 @@ +{ + "chosen_version": "2019-06-01", + "total_api_version_list": ["2019-06-01"], + "client": { + "name": "DeviceServices", + "filename": "_device_services", + "description": "Use this API to manage the Windows IoT device services in your Azure subscription.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "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\": [\"DeviceServicesConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeviceServicesConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "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=\"https://management.azure.com\", # type: 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: str = \"https://management.azure.com\",", + "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_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"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\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "services": "ServicesOperations" + } +} \ No newline at end of file diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_patch.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_vendor.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_version.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_version.py new file mode 100644 index 000000000000..eae7c95b6fbd --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/_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 = "0.1.0" diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/__init__.py new file mode 100644 index 000000000000..4318447c1992 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/__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 ._device_services import DeviceServices +__all__ = ['DeviceServices'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_configuration.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_configuration.py new file mode 100644 index 000000000000..df9e0215244b --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/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, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DeviceServicesConfiguration(Configuration): + """Configuration for DeviceServices. + + 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: + super(DeviceServicesConfiguration, self).__init__(**kwargs) + 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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-windowsiot/{}'.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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_device_services.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_device_services.py new file mode 100644 index 000000000000..67dc38c32bf7 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_device_services.py @@ -0,0 +1,91 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import DeviceServicesConfiguration +from .operations import Operations, ServicesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class DeviceServices: + """Use this API to manage the Windows IoT device services in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.windowsiot.aio.operations.Operations + :ivar services: ServicesOperations operations + :vartype services: azure.mgmt.windowsiot.aio.operations.ServicesOperations + :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 base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DeviceServicesConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DeviceServices": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_patch.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/__init__.py new file mode 100644 index 000000000000..93a0635dd99f --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/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 ._operations import Operations +from ._services_operations import ServicesOperations + +__all__ = [ + 'Operations', + 'ServicesOperations', +] diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_operations.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_operations.py new file mode 100644 index 000000000000..45478c1f837d --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_operations.py @@ -0,0 +1,110 @@ +# 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 functools +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +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.windowsiot.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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists all of the available Windows IoT Services 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.windowsiot.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', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.WindowsIoT/operations'} # type: ignore diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_services_operations.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_services_operations.py new file mode 100644 index 000000000000..55eb53478969 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/aio/operations/_services_operations.py @@ -0,0 +1,494 @@ +# 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 functools +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._services_operations import build_check_device_service_name_availability_request, build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServicesOperations: + """ServicesOperations 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.windowsiot.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 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> "_models.DeviceService": + """Get the non-security related metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + device_name: str, + device_service: "_models.DeviceService", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.DeviceService": + """Create or update the metadata of a Windows IoT Device Service. + + Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a + property is to retrieve the Windows IoT Device Service metadata and security metadata, and then + combine them with the modified values in a new body to update the Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~azure.mgmt.windowsiot.models.DeviceService + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a new + Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(device_service, 'DeviceService') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + device_name: str, + device_service: "_models.DeviceService", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.DeviceService": + """Updates the metadata of a Windows IoT Device Service. + + Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is + to retrieve the Windows IoT Device Service metadata and security metadata, and then combine + them with the modified values in a new body to update the Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~azure.mgmt.windowsiot.models.DeviceService + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a brand + new Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(device_service, 'DeviceService') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> "_models.DeviceService": + """Delete a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.DeviceServiceDescriptionListResult"]: + """Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :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 DeviceServiceDescriptionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeviceServiceDescriptionListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices'} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.DeviceServiceDescriptionListResult"]: + """Get all the IoT hubs 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 DeviceServiceDescriptionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeviceServiceDescriptionListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/deviceServices'} # type: ignore + + @distributed_trace_async + async def check_device_service_name_availability( + self, + device_service_check_name_availability_parameters: "_models.DeviceServiceCheckNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.DeviceServiceNameAvailabilityInfo": + """Check if a Windows IoT Device Service name is available. + + :param device_service_check_name_availability_parameters: Set the name parameter in the + DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device + Service to check. + :type device_service_check_name_availability_parameters: + ~azure.mgmt.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceNameAvailabilityInfo, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceNameAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceServiceNameAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(device_service_check_name_availability_parameters, 'DeviceServiceCheckNameAvailabilityParameters') + + request = build_check_device_service_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_device_service_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceServiceNameAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_device_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/checkDeviceServiceNameAvailability'} # type: ignore + diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/__init__.py new file mode 100644 index 000000000000..853064228ecc --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/__init__.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import DeviceService +from ._models_py3 import DeviceServiceCheckNameAvailabilityParameters +from ._models_py3 import DeviceServiceDescriptionListResult +from ._models_py3 import DeviceServiceNameAvailabilityInfo +from ._models_py3 import ErrorDetails +from ._models_py3 import ErrorDetailsError +from ._models_py3 import OperationDisplayInfo +from ._models_py3 import OperationEntity +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import TrackedResource + + +from ._device_services_enums import ( + ServiceNameUnavailabilityReason, +) + +__all__ = [ + 'DeviceService', + 'DeviceServiceCheckNameAvailabilityParameters', + 'DeviceServiceDescriptionListResult', + 'DeviceServiceNameAvailabilityInfo', + 'ErrorDetails', + 'ErrorDetailsError', + 'OperationDisplayInfo', + 'OperationEntity', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'TrackedResource', + 'ServiceNameUnavailabilityReason', +] diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_device_services_enums.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_device_services_enums.py new file mode 100644 index 000000000000..bacd5f4c0ce8 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_device_services_enums.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 enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class ServiceNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The reason for unavailability. + """ + + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_models_py3.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_models_py3.py new file mode 100644 index 000000000000..0696076ad225 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/models/_models_py3.py @@ -0,0 +1,524 @@ +# 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 + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Resource(msrest.serialization.Model): + """The core properties of ARM resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class DeviceService(TrackedResource): + """The description of the Windows IoT Device Service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal ETag convention. + :vartype etag: str + :ivar notes: Windows IoT Device Service notes. + :vartype notes: str + :ivar start_date: Windows IoT Device Service start date,. + :vartype start_date: ~datetime.datetime + :ivar quantity: Windows IoT Device Service device allocation,. + :vartype quantity: long + :ivar billing_domain_name: Windows IoT Device Service ODM AAD domain. + :vartype billing_domain_name: str + :ivar admin_domain_name: Windows IoT Device Service OEM AAD domain. + :vartype admin_domain_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'start_date': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, + 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, + 'quantity': {'key': 'properties.quantity', 'type': 'long'}, + 'billing_domain_name': {'key': 'properties.billingDomainName', 'type': 'str'}, + 'admin_domain_name': {'key': 'properties.adminDomainName', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + etag: Optional[str] = None, + notes: Optional[str] = None, + quantity: Optional[int] = None, + billing_domain_name: Optional[str] = None, + admin_domain_name: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + :keyword etag: The Etag field is *not* required. If it is provided in the response body, it + must also be provided as a header per the normal ETag convention. + :paramtype etag: str + :keyword notes: Windows IoT Device Service notes. + :paramtype notes: str + :keyword quantity: Windows IoT Device Service device allocation,. + :paramtype quantity: long + :keyword billing_domain_name: Windows IoT Device Service ODM AAD domain. + :paramtype billing_domain_name: str + :keyword admin_domain_name: Windows IoT Device Service OEM AAD domain. + :paramtype admin_domain_name: str + """ + super(DeviceService, self).__init__(tags=tags, location=location, **kwargs) + self.etag = etag + self.notes = notes + self.start_date = None + self.quantity = quantity + self.billing_domain_name = billing_domain_name + self.admin_domain_name = admin_domain_name + + +class DeviceServiceCheckNameAvailabilityParameters(msrest.serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Windows IoT Device Service to check. + :vartype name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. The name of the Windows IoT Device Service to check. + :paramtype name: str + """ + super(DeviceServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) + self.name = name + + +class DeviceServiceDescriptionListResult(msrest.serialization.Model): + """The JSON-serialized array of DeviceService objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of DeviceService objects. + :vartype value: list[~azure.mgmt.windowsiot.models.DeviceService] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceService]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeviceService"]] = None, + **kwargs + ): + """ + :keyword value: The array of DeviceService objects. + :paramtype value: list[~azure.mgmt.windowsiot.models.DeviceService] + """ + super(DeviceServiceDescriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeviceServiceNameAvailabilityInfo(msrest.serialization.Model): + """The properties indicating whether a given Windows IoT Device Service name 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. Possible values include: "Invalid", + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.windowsiot.models.ServiceNameUnavailabilityReason + :ivar message: The detailed reason message. + :vartype message: str + """ + + _validation = { + 'name_available': {'readonly': True}, + 'reason': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ + super(DeviceServiceNameAvailabilityInfo, self).__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = message + + +class ErrorDetails(msrest.serialization.Model): + """The details of the error. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.windowsiot.models.ErrorDetailsError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetailsError'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetailsError"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.windowsiot.models.ErrorDetailsError + """ + super(ErrorDetails, self).__init__(**kwargs) + self.error = error + + +class ErrorDetailsError(msrest.serialization.Model): + """The error object. + + :ivar code: One of a server-defined set of error codes. + :vartype code: str + :ivar message: A human-readable representation of the error. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar details: A human-readable representation of the error's details. + :vartype details: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[str] = None, + **kwargs + ): + """ + :keyword code: One of a server-defined set of error codes. + :paramtype code: str + :keyword message: A human-readable representation of the error. + :paramtype message: str + :keyword target: The target of the particular error. + :paramtype target: str + :keyword details: A human-readable representation of the error's details. + :paramtype details: str + """ + super(ErrorDetailsError, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class OperationDisplayInfo(msrest.serialization.Model): + """The operation supported by Azure Data Catalog Service. + + :ivar description: The description of the operation. + :vartype description: str + :ivar operation: The action that users can perform, based on their permission level. + :vartype operation: str + :ivar provider: Service provider: Azure Data Catalog Service. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + operation: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + **kwargs + ): + """ + :keyword description: The description of the operation. + :paramtype description: str + :keyword operation: The action that users can perform, based on their permission level. + :paramtype operation: str + :keyword provider: Service provider: Azure Data Catalog Service. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + """ + super(OperationDisplayInfo, self).__init__(**kwargs) + self.description = description + self.operation = operation + self.provider = provider + self.resource = resource + + +class OperationEntity(msrest.serialization.Model): + """The operation supported by Azure Data Catalog Service. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The operation supported by Azure Data Catalog Service. + :vartype display: ~azure.mgmt.windowsiot.models.OperationDisplayInfo + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar origin: Indicates the executor of the operation. + :vartype origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplayInfo"] = None, + is_data_action: Optional[bool] = None, + origin: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The operation supported by Azure Data Catalog Service. + :paramtype display: ~azure.mgmt.windowsiot.models.OperationDisplayInfo + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword origin: Indicates the executor of the operation. + :paramtype origin: str + """ + super(OperationEntity, self).__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = is_data_action + self.origin = origin + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Windows IoT Device Service 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. + + :ivar value: List of Windows IoT Device Service operations supported by the + Microsoft.WindowsIoT resource provider. + :vartype value: list[~azure.mgmt.windowsiot.models.OperationEntity] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationEntity]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/__init__.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/__init__.py new file mode 100644 index 000000000000..93a0635dd99f --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/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 ._operations import Operations +from ._services_operations import ServicesOperations + +__all__ = [ + 'Operations', + 'ServicesOperations', +] diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_operations.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_operations.py new file mode 100644 index 000000000000..3bd0064a31a2 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_operations.py @@ -0,0 +1,135 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.WindowsIoT/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +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.windowsiot.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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists all of the available Windows IoT Services 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.windowsiot.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', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.WindowsIoT/operations'} # type: ignore diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_services_operations.py b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_services_operations.py new file mode 100644 index 000000000000..f318a9762124 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/operations/_services_operations.py @@ -0,0 +1,764 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + device_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + device_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + device_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + device_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/deviceServices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_device_service_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/checkDeviceServiceNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class ServicesOperations(object): + """ServicesOperations 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.windowsiot.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 + + @distributed_trace + def get( + self, + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> "_models.DeviceService": + """Get the non-security related metadata of a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + device_name: str, + device_service: "_models.DeviceService", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.DeviceService": + """Create or update the metadata of a Windows IoT Device Service. + + Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a + property is to retrieve the Windows IoT Device Service metadata and security metadata, and then + combine them with the modified values in a new body to update the Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~azure.mgmt.windowsiot.models.DeviceService + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a new + Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(device_service, 'DeviceService') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + device_name: str, + device_service: "_models.DeviceService", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.DeviceService": + """Updates the metadata of a Windows IoT Device Service. + + Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is + to retrieve the Windows IoT Device Service metadata and security metadata, and then combine + them with the modified values in a new body to update the Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :param device_service: The Windows IoT Device Service metadata and security metadata. + :type device_service: ~azure.mgmt.windowsiot.models.DeviceService + :param if_match: ETag of the Windows IoT Device Service. Do not specify for creating a brand + new Windows IoT Device Service. Required to update an existing Windows IoT Device Service. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(device_service, 'DeviceService') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> "_models.DeviceService": + """Delete a Windows IoT Device Service. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :type resource_group_name: str + :param device_name: The name of the Windows IoT Device Service. + :type device_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceService, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceService + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceService"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + device_name=device_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('DeviceService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices/{deviceName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DeviceServiceDescriptionListResult"]: + """Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the Windows IoT Device + Service. + :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 DeviceServiceDescriptionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeviceServiceDescriptionListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT/deviceServices'} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.DeviceServiceDescriptionListResult"]: + """Get all the IoT hubs 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 DeviceServiceDescriptionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.windowsiot.models.DeviceServiceDescriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceServiceDescriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeviceServiceDescriptionListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/deviceServices'} # type: ignore + + @distributed_trace + def check_device_service_name_availability( + self, + device_service_check_name_availability_parameters: "_models.DeviceServiceCheckNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.DeviceServiceNameAvailabilityInfo": + """Check if a Windows IoT Device Service name is available. + + :param device_service_check_name_availability_parameters: Set the name parameter in the + DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device + Service to check. + :type device_service_check_name_availability_parameters: + ~azure.mgmt.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceServiceNameAvailabilityInfo, or the result of cls(response) + :rtype: ~azure.mgmt.windowsiot.models.DeviceServiceNameAvailabilityInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceServiceNameAvailabilityInfo"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(device_service_check_name_availability_parameters, 'DeviceServiceCheckNameAvailabilityParameters') + + request = build_check_device_service_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_device_service_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeviceServiceNameAvailabilityInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_device_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/checkDeviceServiceNameAvailability'} # type: ignore + diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/py.typed b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/azure/mgmt/windowsiot/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/sdk_packaging.toml b/sdk/windowsiot/azure-mgmt-windowsiot/sdk_packaging.toml new file mode 100644 index 000000000000..2e3fc491bd0d --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-windowsiot" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/windowsiot/azure-mgmt-windowsiot/setup.py b/sdk/windowsiot/azure-mgmt-windowsiot/setup.py new file mode 100644 index 000000000000..94d7c89299cc --- /dev/null +++ b/sdk/windowsiot/azure-mgmt-windowsiot/setup.py @@ -0,0 +1,74 @@ +#!/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-windowsiot" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# 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', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + '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.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/windowsiot/ci.yml b/sdk/windowsiot/ci.yml new file mode 100644 index 000000000000..e54a714c0ef8 --- /dev/null +++ b/sdk/windowsiot/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/windowsiot/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/windowsiot/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: windowsiot + Artifacts: + - name: azure-mgmt-windowsiot + safeName: azuremgmtwindowsiot