diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/CHANGELOG.md b/sdk/digitaltwins/azure-mgmt-digitaltwins/CHANGELOG.md index aef89abe8fff..759f7bb6d888 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/CHANGELOG.md +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 7.0.0 (2024-10-30) + +### Breaking Changes + + - This package now only targets the latest Api-Version available on Azure and removes APIs of other Api-Version. After this change, the package can have much smaller size. If your application requires a specific and non-latest Api-Version, it's recommended to pin this package to the previous released version; If your application always only use latest Api-Version, please ingore this change. + ## 6.4.0 (2023-03-20) ### Features Added diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/README.md b/sdk/digitaltwins/azure-mgmt-digitaltwins/README.md index ce0c5ca212fc..2430acc4e47b 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/README.md +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Digital Twins Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -45,8 +45,9 @@ client = AzureDigitalTwinsManagementClient(credential=DefaultAzureCredential(), ## Examples - -Code samples for this package can be found at [Digital Twins Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) +Code samples for this package can be found at: +- [Search Digital Twins Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) ## Troubleshooting @@ -58,6 +59,3 @@ Code samples for this package can be found at [Digital Twins Management](https:/ 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-digitaltwins%2FREADME.png) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/_meta.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/_meta.json index aeba41aa99a5..74cfbeec10c9 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/_meta.json +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/_meta.json @@ -1,11 +1,11 @@ { - "commit": "d1b57073903fc64486bf53a37f061e5c7ab9ca31", + "commit": "2776cb32cd6ca9ea953a13ae26c954b989e83367", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.0", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/digitaltwins/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/digitaltwins/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/digitaltwins/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/assets.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/assets.json deleted file mode 100644 index a2faf408a77c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "python", - "TagPrefix": "python/digitaltwins/azure-mgmt-digitaltwins", - "Tag": "python/digitaltwins/azure-mgmt-digitaltwins_599376896c" -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/__init__.py index 2a8346ceded2..3d416a868dd2 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/__init__.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/__init__.py @@ -7,14 +7,20 @@ # -------------------------------------------------------------------------- from ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -__all__ = ['AzureDigitalTwinsManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk -from ._version import VERSION +__all__ = [ + "AzureDigitalTwinsManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) -__version__ = VERSION +_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_azure_digital_twins_management_client.py index f1240dde1115..a6287cdb74fe 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_azure_digital_twins_management_client.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_azure_digital_twins_management_client.py @@ -1,297 +1,146 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from . import models as _models from ._configuration import AzureDigitalTwinsManagementClientConfiguration from ._serialization import Deserializer, Serializer +from .operations import ( + DigitalTwinsEndpointOperations, + DigitalTwinsOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + TimeSeriesDatabaseConnectionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class AzureDigitalTwinsManagementClient(MultiApiClientMixin, _SDKClient): +class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword """Azure Digital Twins Client for managing DigitalTwinsInstance. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar digital_twins: DigitalTwinsOperations operations + :vartype digital_twins: azure.mgmt.digitaltwins.operations.DigitalTwinsOperations + :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations + :vartype digital_twins_endpoint: + azure.mgmt.digitaltwins.operations.DigitalTwinsEndpointOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.digitaltwins.operations.Operations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.digitaltwins.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.digitaltwins.operations.PrivateEndpointConnectionsOperations + :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations + :vartype time_series_database_connections: + azure.mgmt.digitaltwins.operations.TimeSeriesDatabaseConnectionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-31' - _PROFILE_TAG = "azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - }}, - _PROFILE_TAG + " latest" - ) - def __init__( self, credential: "TokenCredential", subscription_id: str, - api_version: Optional[str]=None, base_url: str = "https://management.azure.com", - profile: KnownProfiles=KnownProfiles.default, **kwargs: Any - ): - self._config = AzureDigitalTwinsManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(AzureDigitalTwinsManagementClient, self).__init__( - api_version=api_version, - profile=profile + ) -> None: + self._config = AzureDigitalTwinsManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) + self.digital_twins_endpoint = DigitalTwinsEndpointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2020-03-01-preview: :mod:`v2020_03_01_preview.models` - * 2020-10-31: :mod:`v2020_10_31.models` - * 2020-12-01: :mod:`v2020_12_01.models` - * 2021-06-30-preview: :mod:`v2021_06_30_preview.models` - * 2022-05-31: :mod:`v2022_05_31.models` - * 2022-10-31: :mod:`v2022_10_31.models` - * 2023-01-31: :mod:`v2023_01_31.models` - """ - if api_version == '2020-03-01-preview': - from .v2020_03_01_preview import models - return models - elif api_version == '2020-10-31': - from .v2020_10_31 import models - return models - elif api_version == '2020-12-01': - from .v2020_12_01 import models - return models - elif api_version == '2021-06-30-preview': - from .v2021_06_30_preview import models - return models - elif api_version == '2022-05-31': - from .v2022_05_31 import models - return models - elif api_version == '2022-10-31': - from .v2022_10_31 import models - return models - elif api_version == '2023-01-31': - from .v2023_01_31 import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def digital_twins(self): - """Instance depends on the API version: - - * 2020-03-01-preview: :class:`DigitalTwinsOperations` - * 2020-10-31: :class:`DigitalTwinsOperations` - * 2020-12-01: :class:`DigitalTwinsOperations` - * 2021-06-30-preview: :class:`DigitalTwinsOperations` - * 2022-05-31: :class:`DigitalTwinsOperations` - * 2022-10-31: :class:`DigitalTwinsOperations` - * 2023-01-31: :class:`DigitalTwinsOperations` - """ - api_version = self._get_api_version('digital_twins') - if api_version == '2020-03-01-preview': - from .v2020_03_01_preview.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2020-10-31': - from .v2020_10_31.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2020-12-01': - from .v2020_12_01.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2021-06-30-preview': - from .v2021_06_30_preview.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2022-05-31': - from .v2022_05_31.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2022-10-31': - from .v2022_10_31.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2023-01-31': - from .v2023_01_31.operations import DigitalTwinsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'digital_twins'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def digital_twins_endpoint(self): - """Instance depends on the API version: - - * 2020-03-01-preview: :class:`DigitalTwinsEndpointOperations` - * 2020-10-31: :class:`DigitalTwinsEndpointOperations` - * 2020-12-01: :class:`DigitalTwinsEndpointOperations` - * 2021-06-30-preview: :class:`DigitalTwinsEndpointOperations` - * 2022-05-31: :class:`DigitalTwinsEndpointOperations` - * 2022-10-31: :class:`DigitalTwinsEndpointOperations` - * 2023-01-31: :class:`DigitalTwinsEndpointOperations` - """ - api_version = self._get_api_version('digital_twins_endpoint') - if api_version == '2020-03-01-preview': - from .v2020_03_01_preview.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2020-10-31': - from .v2020_10_31.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2020-12-01': - from .v2020_12_01.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2021-06-30-preview': - from .v2021_06_30_preview.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2022-05-31': - from .v2022_05_31.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2022-10-31': - from .v2022_10_31.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2023-01-31': - from .v2023_01_31.operations import DigitalTwinsEndpointOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'digital_twins_endpoint'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def operations(self): - """Instance depends on the API version: - - * 2020-03-01-preview: :class:`Operations` - * 2020-10-31: :class:`Operations` - * 2020-12-01: :class:`Operations` - * 2021-06-30-preview: :class:`Operations` - * 2022-05-31: :class:`Operations` - * 2022-10-31: :class:`Operations` - * 2023-01-31: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2020-03-01-preview': - from .v2020_03_01_preview.operations import Operations as OperationClass - elif api_version == '2020-10-31': - from .v2020_10_31.operations import Operations as OperationClass - elif api_version == '2020-12-01': - from .v2020_12_01.operations import Operations as OperationClass - elif api_version == '2021-06-30-preview': - from .v2021_06_30_preview.operations import Operations as OperationClass - elif api_version == '2022-05-31': - from .v2022_05_31.operations import Operations as OperationClass - elif api_version == '2022-10-31': - from .v2022_10_31.operations import Operations as OperationClass - elif api_version == '2023-01-31': - from .v2023_01_31.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_endpoint_connections(self): - """Instance depends on the API version: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - * 2020-12-01: :class:`PrivateEndpointConnectionsOperations` - * 2021-06-30-preview: :class:`PrivateEndpointConnectionsOperations` - * 2022-05-31: :class:`PrivateEndpointConnectionsOperations` - * 2022-10-31: :class:`PrivateEndpointConnectionsOperations` - * 2023-01-31: :class:`PrivateEndpointConnectionsOperations` - """ - api_version = self._get_api_version('private_endpoint_connections') - if api_version == '2020-12-01': - from .v2020_12_01.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-06-30-preview': - from .v2021_06_30_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2022-05-31': - from .v2022_05_31.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2022-10-31': - from .v2022_10_31.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2023-01-31': - from .v2023_01_31.operations import PrivateEndpointConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - @property - def private_link_resources(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2020-12-01: :class:`PrivateLinkResourcesOperations` - * 2021-06-30-preview: :class:`PrivateLinkResourcesOperations` - * 2022-05-31: :class:`PrivateLinkResourcesOperations` - * 2022-10-31: :class:`PrivateLinkResourcesOperations` - * 2023-01-31: :class:`PrivateLinkResourcesOperations` + :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 """ - api_version = self._get_api_version('private_link_resources') - if api_version == '2020-12-01': - from .v2020_12_01.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2021-06-30-preview': - from .v2021_06_30_preview.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2022-05-31': - from .v2022_05_31.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2022-10-31': - from .v2022_10_31.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2023-01-31': - from .v2023_01_31.operations import PrivateLinkResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def time_series_database_connections(self): - """Instance depends on the API version: - * 2021-06-30-preview: :class:`TimeSeriesDatabaseConnectionsOperations` - * 2022-05-31: :class:`TimeSeriesDatabaseConnectionsOperations` - * 2022-10-31: :class:`TimeSeriesDatabaseConnectionsOperations` - * 2023-01-31: :class:`TimeSeriesDatabaseConnectionsOperations` - """ - api_version = self._get_api_version('time_series_database_connections') - if api_version == '2021-06-30-preview': - from .v2021_06_30_preview.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - elif api_version == '2022-05-31': - from .v2022_05_31.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - elif api_version == '2022-10-31': - from .v2022_10_31.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - elif api_version == '2023-01-31': - from .v2023_01_31.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'time_series_database_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - def close(self): + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_configuration.py index a46b6e69bf48..1e9bfc01b157 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_configuration.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_configuration.py @@ -1,16 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# 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 @@ -20,7 +17,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AzureDigitalTwinsManagementClientConfiguration(Configuration): + +class AzureDigitalTwinsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AzureDigitalTwinsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -30,38 +28,38 @@ class AzureDigitalTwinsManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-01-31") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-digitaltwins/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - 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') + 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_patch.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_patch.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_patch.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_serialization.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_serialization.py index 25467dfc00bb..8139854b97bb 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_serialization.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,14 +346,12 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[ - [str, Dict[str, Any], Any], Any - ] = attribute_transformer, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -392,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -417,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -447,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -547,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -631,7 +624,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -651,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -664,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -711,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -731,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -743,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -751,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -805,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -825,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -893,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -905,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -985,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1162,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1201,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1222,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1273,7 +1275,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1297,7 +1299,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1363,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1383,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1436,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1473,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1507,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1570,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1644,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1692,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1749,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1800,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1854,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1885,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1902,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1937,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1974,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1990,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_version.py index 2f4dad6be59a..364f3c906cf9 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_version.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_version.py @@ -1,8 +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. +# 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 = "6.4.0" +VERSION = "7.0.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/__init__.py index c42c1ad6def4..e4da5a5dc30c 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/__init__.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -__all__ = ['AzureDigitalTwinsManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureDigitalTwinsManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_azure_digital_twins_management_client.py index dc25478cc9e3..ef60bc9be41e 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_azure_digital_twins_management_client.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_azure_digital_twins_management_client.py @@ -1,297 +1,148 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AzureDigitalTwinsManagementClientConfiguration +from .operations import ( + DigitalTwinsEndpointOperations, + DigitalTwinsOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + TimeSeriesDatabaseConnectionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class AzureDigitalTwinsManagementClient(MultiApiClientMixin, _SDKClient): +class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword """Azure Digital Twins Client for managing DigitalTwinsInstance. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar digital_twins: DigitalTwinsOperations operations + :vartype digital_twins: azure.mgmt.digitaltwins.aio.operations.DigitalTwinsOperations + :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations + :vartype digital_twins_endpoint: + azure.mgmt.digitaltwins.aio.operations.DigitalTwinsEndpointOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.digitaltwins.aio.operations.Operations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.digitaltwins.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.digitaltwins.aio.operations.PrivateEndpointConnectionsOperations + :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations + :vartype time_series_database_connections: + azure.mgmt.digitaltwins.aio.operations.TimeSeriesDatabaseConnectionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-31' - _PROFILE_TAG = "azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - }}, - _PROFILE_TAG + " latest" - ) - def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - api_version: Optional[str] = None, base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(AzureDigitalTwinsManagementClient, self).__init__( - api_version=api_version, - profile=profile + self._config = AzureDigitalTwinsManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) + self.digital_twins_endpoint = DigitalTwinsEndpointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2020-03-01-preview: :mod:`v2020_03_01_preview.models` - * 2020-10-31: :mod:`v2020_10_31.models` - * 2020-12-01: :mod:`v2020_12_01.models` - * 2021-06-30-preview: :mod:`v2021_06_30_preview.models` - * 2022-05-31: :mod:`v2022_05_31.models` - * 2022-10-31: :mod:`v2022_10_31.models` - * 2023-01-31: :mod:`v2023_01_31.models` - """ - if api_version == '2020-03-01-preview': - from ..v2020_03_01_preview import models - return models - elif api_version == '2020-10-31': - from ..v2020_10_31 import models - return models - elif api_version == '2020-12-01': - from ..v2020_12_01 import models - return models - elif api_version == '2021-06-30-preview': - from ..v2021_06_30_preview import models - return models - elif api_version == '2022-05-31': - from ..v2022_05_31 import models - return models - elif api_version == '2022-10-31': - from ..v2022_10_31 import models - return models - elif api_version == '2023-01-31': - from ..v2023_01_31 import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def digital_twins(self): - """Instance depends on the API version: - - * 2020-03-01-preview: :class:`DigitalTwinsOperations` - * 2020-10-31: :class:`DigitalTwinsOperations` - * 2020-12-01: :class:`DigitalTwinsOperations` - * 2021-06-30-preview: :class:`DigitalTwinsOperations` - * 2022-05-31: :class:`DigitalTwinsOperations` - * 2022-10-31: :class:`DigitalTwinsOperations` - * 2023-01-31: :class:`DigitalTwinsOperations` - """ - api_version = self._get_api_version('digital_twins') - if api_version == '2020-03-01-preview': - from ..v2020_03_01_preview.aio.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2020-10-31': - from ..v2020_10_31.aio.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2020-12-01': - from ..v2020_12_01.aio.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2021-06-30-preview': - from ..v2021_06_30_preview.aio.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2022-05-31': - from ..v2022_05_31.aio.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2022-10-31': - from ..v2022_10_31.aio.operations import DigitalTwinsOperations as OperationClass - elif api_version == '2023-01-31': - from ..v2023_01_31.aio.operations import DigitalTwinsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'digital_twins'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def digital_twins_endpoint(self): - """Instance depends on the API version: - - * 2020-03-01-preview: :class:`DigitalTwinsEndpointOperations` - * 2020-10-31: :class:`DigitalTwinsEndpointOperations` - * 2020-12-01: :class:`DigitalTwinsEndpointOperations` - * 2021-06-30-preview: :class:`DigitalTwinsEndpointOperations` - * 2022-05-31: :class:`DigitalTwinsEndpointOperations` - * 2022-10-31: :class:`DigitalTwinsEndpointOperations` - * 2023-01-31: :class:`DigitalTwinsEndpointOperations` - """ - api_version = self._get_api_version('digital_twins_endpoint') - if api_version == '2020-03-01-preview': - from ..v2020_03_01_preview.aio.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2020-10-31': - from ..v2020_10_31.aio.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2020-12-01': - from ..v2020_12_01.aio.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2021-06-30-preview': - from ..v2021_06_30_preview.aio.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2022-05-31': - from ..v2022_05_31.aio.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2022-10-31': - from ..v2022_10_31.aio.operations import DigitalTwinsEndpointOperations as OperationClass - elif api_version == '2023-01-31': - from ..v2023_01_31.aio.operations import DigitalTwinsEndpointOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'digital_twins_endpoint'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def operations(self): - """Instance depends on the API version: - - * 2020-03-01-preview: :class:`Operations` - * 2020-10-31: :class:`Operations` - * 2020-12-01: :class:`Operations` - * 2021-06-30-preview: :class:`Operations` - * 2022-05-31: :class:`Operations` - * 2022-10-31: :class:`Operations` - * 2023-01-31: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2020-03-01-preview': - from ..v2020_03_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2020-10-31': - from ..v2020_10_31.aio.operations import Operations as OperationClass - elif api_version == '2020-12-01': - from ..v2020_12_01.aio.operations import Operations as OperationClass - elif api_version == '2021-06-30-preview': - from ..v2021_06_30_preview.aio.operations import Operations as OperationClass - elif api_version == '2022-05-31': - from ..v2022_05_31.aio.operations import Operations as OperationClass - elif api_version == '2022-10-31': - from ..v2022_10_31.aio.operations import Operations as OperationClass - elif api_version == '2023-01-31': - from ..v2023_01_31.aio.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_endpoint_connections(self): - """Instance depends on the API version: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - * 2020-12-01: :class:`PrivateEndpointConnectionsOperations` - * 2021-06-30-preview: :class:`PrivateEndpointConnectionsOperations` - * 2022-05-31: :class:`PrivateEndpointConnectionsOperations` - * 2022-10-31: :class:`PrivateEndpointConnectionsOperations` - * 2023-01-31: :class:`PrivateEndpointConnectionsOperations` - """ - api_version = self._get_api_version('private_endpoint_connections') - if api_version == '2020-12-01': - from ..v2020_12_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-06-30-preview': - from ..v2021_06_30_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2022-05-31': - from ..v2022_05_31.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2022-10-31': - from ..v2022_10_31.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2023-01-31': - from ..v2023_01_31.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - @property - def private_link_resources(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2020-12-01: :class:`PrivateLinkResourcesOperations` - * 2021-06-30-preview: :class:`PrivateLinkResourcesOperations` - * 2022-05-31: :class:`PrivateLinkResourcesOperations` - * 2022-10-31: :class:`PrivateLinkResourcesOperations` - * 2023-01-31: :class:`PrivateLinkResourcesOperations` + :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 """ - api_version = self._get_api_version('private_link_resources') - if api_version == '2020-12-01': - from ..v2020_12_01.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2021-06-30-preview': - from ..v2021_06_30_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2022-05-31': - from ..v2022_05_31.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2022-10-31': - from ..v2022_10_31.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2023-01-31': - from ..v2023_01_31.aio.operations import PrivateLinkResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def time_series_database_connections(self): - """Instance depends on the API version: - * 2021-06-30-preview: :class:`TimeSeriesDatabaseConnectionsOperations` - * 2022-05-31: :class:`TimeSeriesDatabaseConnectionsOperations` - * 2022-10-31: :class:`TimeSeriesDatabaseConnectionsOperations` - * 2023-01-31: :class:`TimeSeriesDatabaseConnectionsOperations` - """ - api_version = self._get_api_version('time_series_database_connections') - if api_version == '2021-06-30-preview': - from ..v2021_06_30_preview.aio.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - elif api_version == '2022-05-31': - from ..v2022_05_31.aio.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - elif api_version == '2022-10-31': - from ..v2022_10_31.aio.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - elif api_version == '2023-01-31': - from ..v2023_01_31.aio.operations import TimeSeriesDatabaseConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'time_series_database_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - async def close(self): + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_configuration.py index 2da0dcb0a8aa..a7c2db97961d 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_configuration.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_configuration.py @@ -1,16 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# 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 @@ -20,7 +17,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AzureDigitalTwinsManagementClientConfiguration(Configuration): + +class AzureDigitalTwinsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AzureDigitalTwinsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -30,38 +28,38 @@ class AzureDigitalTwinsManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-01-31") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-digitaltwins/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) 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') + 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_patch.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_patch.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/_patch.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/__init__.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/__init__.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/__init__.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_digital_twins_endpoint_operations.py similarity index 67% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_digital_twins_endpoint_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_digital_twins_endpoint_operations.py index dbc45f172d6c..c046b8bbfd21 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_digital_twins_endpoint_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_digital_twins_endpoint_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._digital_twins_endpoint_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ class DigitalTwinsEndpointOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.aio.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.aio.AzureDigitalTwinsManagementClient`'s :attr:`digital_twins_endpoint` attribute. """ @@ -76,20 +77,19 @@ def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DigitalTwinsEndpointResourceListResult", pipeline_response) @@ -138,10 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any @@ -171,12 +165,11 @@ async def get( :type resource_name: str :param endpoint_name: Name of Endpoint Resource. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource + :rtype: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,24 +180,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -214,26 +206,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], + endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO[bytes]], **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,19 +232,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(endpoint_description, (IO, bytes)): + if isinstance(endpoint_description, (IOBase, bytes)): _content = endpoint_description else: _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, endpoint_name=endpoint_name, @@ -265,39 +253,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - @overload async def begin_create_or_update( self, @@ -320,23 +304,14 @@ async def begin_create_or_update( :type endpoint_name: str :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource + :type endpoint_description: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -346,7 +321,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, endpoint_name: str, - endpoint_description: IO, + endpoint_description: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -362,22 +337,14 @@ async def begin_create_or_update( :type endpoint_name: str :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. Required. - :type endpoint_description: IO + :type endpoint_description: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -387,7 +354,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], + endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: """Create or update DigitalTwinsInstance endpoint. @@ -400,30 +367,19 @@ async def begin_create_or_update( :param endpoint_name: Name of Endpoint Resource. Required. :type endpoint_name: str :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + Is either a DigitalTwinsEndpointResource type or a IO[bytes] type. Required. + :type endpoint_description: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource or + IO[bytes] :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -442,12 +398,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -457,22 +414,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DigitalTwinsEndpointResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return AsyncLROPoller[_models.DigitalTwinsEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,48 +438,43 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -539,24 +489,16 @@ async def begin_delete( :type resource_name: str :param endpoint_name: Name of Endpoint Resource. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -572,12 +514,13 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -587,14 +530,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DigitalTwinsEndpointResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return AsyncLROPoller[_models.DigitalTwinsEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_digital_twins_operations.py similarity index 67% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_digital_twins_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_digital_twins_operations.py index c2597b3b2224..afcd88c509d2 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_digital_twins_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_digital_twins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._digital_twins_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -41,10 +42,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +56,7 @@ class DigitalTwinsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_10_31.aio.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.aio.AzureDigitalTwinsManagementClient`'s :attr:`digital_twins` attribute. """ @@ -77,12 +78,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :rtype: ~azure.mgmt.digitaltwins.models.DigitalTwinsDescription :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,23 +93,22 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,25 +118,21 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], + digital_twins_create: Union[_models.DigitalTwinsDescription, IO[bytes]], **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,19 +143,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(digital_twins_create, (IO, bytes)): + if isinstance(digital_twins_create, (IOBase, bytes)): _content = digital_twins_create else: _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -168,39 +163,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - @overload async def begin_create_or_update( self, @@ -221,22 +212,14 @@ async def begin_create_or_update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :type digital_twins_create: ~azure.mgmt.digitaltwins.models.DigitalTwinsDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -245,7 +228,7 @@ async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - digital_twins_create: IO, + digital_twins_create: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -260,22 +243,14 @@ async def begin_create_or_update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO + :type digital_twins_create: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -284,7 +259,7 @@ async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], + digital_twins_create: Union[_models.DigitalTwinsDescription, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property @@ -297,30 +272,19 @@ async def begin_create_or_update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + DigitalTwinsDescription type or a IO[bytes] type. Required. + :type digital_twins_create: ~azure.mgmt.digitaltwins.models.DigitalTwinsDescription or + IO[bytes] :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -338,12 +302,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -353,20 +318,85 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DigitalTwinsDescription].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.DigitalTwinsDescription]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(digital_twins_patch_description, (IOBase, bytes)): + _content = digital_twins_patch_description + else: + _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - async def update( + async def begin_update( self, resource_group_name: str, resource_name: str, @@ -374,7 +404,7 @@ async def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DigitalTwinsDescription: + ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: """Update metadata of DigitalTwinsInstance. :param resource_group_name: The name of the resource group that contains the @@ -385,26 +415,27 @@ async def update( :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Required. :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsPatchDescription + ~azure.mgmt.digitaltwins.models.DigitalTwinsPatchDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_update( self, resource_group_name: str, resource_name: str, - digital_twins_patch_description: IO, + digital_twins_patch_description: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DigitalTwinsDescription: + ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: """Update metadata of DigitalTwinsInstance. :param resource_group_name: The name of the resource group that contains the @@ -414,24 +445,25 @@ async def update( :type resource_name: str :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_patch_description: IO + :type digital_twins_patch_description: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def begin_update( self, resource_group_name: str, resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], + digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO[bytes]], **kwargs: Any - ) -> _models.DigitalTwinsDescription: + ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: """Update metadata of DigitalTwinsInstance. :param resource_group_name: The name of the resource group that contains the @@ -440,81 +472,66 @@ async def update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. + either a DigitalTwinsPatchDescription type or a IO[bytes] type. Required. :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + ~azure.mgmt.digitaltwins.models.DigitalTwinsPatchDescription or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + digital_twins_patch_description=digital_twins_patch_description, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DigitalTwinsDescription].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DigitalTwinsDescription]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - async def _delete_initial( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,47 +542,42 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -578,24 +590,16 @@ async def begin_delete( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -610,12 +614,13 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -625,36 +630,33 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DigitalTwinsDescription].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + return AsyncLROPoller[_models.DigitalTwinsDescription]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -665,15 +667,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription" def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -685,13 +685,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DigitalTwinsDescriptionListResult", pipeline_response) @@ -701,10 +700,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -717,8 +717,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -728,20 +726,19 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the DigitalTwinsInstance. Required. :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 DigitalTwinsDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -752,16 +749,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -773,13 +768,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DigitalTwinsDescriptionListResult", pipeline_response) @@ -789,10 +783,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -805,10 +800,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - } - @overload async def check_name_availability( self, @@ -825,14 +816,12 @@ async def check_name_availability( :param digital_twins_instance_check_name: Set the name parameter in the DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameRequest + :type digital_twins_instance_check_name: ~azure.mgmt.digitaltwins.models.CheckNameRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameResult + :rtype: ~azure.mgmt.digitaltwins.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -840,7 +829,7 @@ async def check_name_availability( async def check_name_availability( self, location: str, - digital_twins_instance_check_name: IO, + digital_twins_instance_check_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -852,19 +841,21 @@ async def check_name_availability( :param digital_twins_instance_check_name: Set the name parameter in the DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Required. - :type digital_twins_instance_check_name: IO + :type digital_twins_instance_check_name: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameResult + :rtype: ~azure.mgmt.digitaltwins.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any + self, + location: str, + digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameResult: """Check if a DigitalTwinsInstance name is available. @@ -872,18 +863,14 @@ async def check_name_availability( :type location: str :param digital_twins_instance_check_name: Set the name parameter in the DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + either a CheckNameRequest type or a IO[bytes] type. Required. + :type digital_twins_instance_check_name: ~azure.mgmt.digitaltwins.models.CheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameResult + :rtype: ~azure.mgmt.digitaltwins.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -894,34 +881,33 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): + if isinstance(digital_twins_instance_check_name, (IOBase, bytes)): _content = digital_twins_instance_check_name else: _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -931,13 +917,9 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_operations.py similarity index 75% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_operations.py index b110f72befc3..70bb5bcc8605 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,20 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +42,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.aio.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.aio.AzureDigitalTwinsManagementClient`'s :attr:`operations` attribute. """ @@ -61,19 +59,17 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.Operation] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,14 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -103,13 +97,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return 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) @@ -119,10 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_patch.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_patch.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_patch.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_private_endpoint_connections_operations.py similarity index 67% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_private_endpoint_connections_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_private_endpoint_connections_operations.py index ad3931b9a04f..ea2bf3b82964 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,19 +16,19 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_create_or_update_request, build_delete_request, @@ -35,10 +36,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ class PrivateEndpointConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.aio.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.aio.AzureDigitalTwinsManagementClient`'s :attr:`private_endpoint_connections` attribute. """ @@ -73,12 +74,11 @@ async def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnectionsResponse + :rtype: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnectionsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,23 +89,22 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,16 +114,12 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -139,12 +134,11 @@ async def get( :type resource_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection + :rtype: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,24 +149,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,21 +175,17 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,39 +196,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -254,14 +247,6 @@ async def begin_delete( :type resource_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -269,13 +254,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -285,11 +270,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -298,27 +284,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,19 +311,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -350,39 +332,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -405,23 +383,14 @@ async def begin_create_or_update( :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection + :type private_endpoint_connection: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -431,7 +400,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -447,22 +416,14 @@ async def begin_create_or_update( :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -472,7 +433,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the status of a private endpoint connection with the given name. @@ -485,30 +446,19 @@ async def begin_create_or_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type private_endpoint_connection: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnection or + IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -527,12 +477,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -542,14 +493,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_private_link_resources_operations.py similarity index 72% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_private_link_resources_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_private_link_resources_operations.py index 330d22e5cd94..2d17ce3f95ce 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_private_link_resources_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +40,7 @@ class PrivateLinkResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.aio.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.aio.AzureDigitalTwinsManagementClient`'s :attr:`private_link_resources` attribute. """ @@ -66,12 +64,11 @@ async def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformationResponse + :rtype: ~azure.mgmt.digitaltwins.models.GroupIdInformationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,23 +79,22 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,16 +104,12 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) + deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -132,12 +124,11 @@ async def get( :type resource_name: str :param resource_id: The name of the private link resource. Required. :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformation + :rtype: ~azure.mgmt.digitaltwins.models.GroupIdInformation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,24 +139,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, resource_id=resource_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,13 +165,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupIdInformation", pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } + return deserialized # type: ignore diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_time_series_database_connections_operations.py similarity index 69% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_time_series_database_connections_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_time_series_database_connections_operations.py index 91ae23443edd..7f3f14dffbb6 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_time_series_database_connections_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/aio/operations/_time_series_database_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._time_series_database_connections_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +39,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ class TimeSeriesDatabaseConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.aio.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.aio.AzureDigitalTwinsManagementClient`'s :attr:`time_series_database_connections` attribute. """ @@ -76,20 +77,19 @@ def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("TimeSeriesDatabaseConnectionListResult", pipeline_response) @@ -138,10 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any @@ -171,12 +165,11 @@ async def get( :type resource_name: str :param time_series_database_connection_name: Name of time series database connection. Required. :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection + :rtype: ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,24 +180,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, time_series_database_connection_name=time_series_database_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -214,26 +206,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], + time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO[bytes]], **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,19 +232,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): + if isinstance(time_series_database_connection_description, (IOBase, bytes)): _content = time_series_database_connection_description else: _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, time_series_database_connection_name=time_series_database_connection_name, @@ -265,39 +253,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -321,22 +305,14 @@ async def begin_create_or_update( :param time_series_database_connection_description: The time series database connection description. Required. :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection + ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -346,7 +322,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, time_series_database_connection_name: str, - time_series_database_connection_description: IO, + time_series_database_connection_description: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -362,22 +338,14 @@ async def begin_create_or_update( :type time_series_database_connection_name: str :param time_series_database_connection_description: The time series database connection description. Required. - :type time_series_database_connection_description: IO + :type time_series_database_connection_description: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -387,7 +355,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], + time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: """Create or update a time series database connection. @@ -400,30 +368,19 @@ async def begin_create_or_update( :param time_series_database_connection_name: Name of time series database connection. Required. :type time_series_database_connection_name: str :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. + description. Is either a TimeSeriesDatabaseConnection type or a IO[bytes] type. Required. :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -442,12 +399,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -457,17 +415,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.TimeSeriesDatabaseConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return AsyncLROPoller[_models.TimeSeriesDatabaseConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, @@ -476,8 +432,8 @@ async def _delete_initial( time_series_database_connection_name: str, cleanup_connection_artifacts: Optional[Union[str, _models.CleanupConnectionArtifacts]] = None, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,49 +444,44 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, time_series_database_connection_name=time_series_database_connection_name, subscription_id=self._config.subscription_id, cleanup_connection_artifacts=cleanup_connection_artifacts, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -556,25 +507,17 @@ async def begin_delete( 'true' does not delete any recorded data. Known values are: "true" and "false". Default value is None. :type cleanup_connection_artifacts: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.CleanupConnectionArtifacts - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.digitaltwins.models.CleanupConnectionArtifacts :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -591,12 +534,13 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -606,14 +550,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.TimeSeriesDatabaseConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return AsyncLROPoller[_models.TimeSeriesDatabaseConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models.py deleted file mode 100644 index fa49df90ed14..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models.py +++ /dev/null @@ -1,7 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from .v2023_01_31.models import * diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/__init__.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/__init__.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/__init__.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_azure_digital_twins_management_client_enums.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_azure_digital_twins_management_client_enums.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_azure_digital_twins_management_client_enums.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_models_py3.py similarity index 87% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_models_py3.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_models_py3.py index 4ed5aab50313..e264579644ab 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_models_py3.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_models_py3.py @@ -10,7 +10,7 @@ import datetime from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from ... import _serialization +from .. import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -25,18 +25,18 @@ class TimeSeriesDatabaseConnectionProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar connection_type: The type of time series connection resource. Required. "AzureDataExplorer" - :vartype connection_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionType + :vartype connection_type: str or ~azure.mgmt.digitaltwins.models.ConnectionType :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", and "Disabled". :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnectionState + ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnectionState :ivar identity: Managed identity properties for the time series database connection resource. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :vartype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference """ _validation = { @@ -56,7 +56,7 @@ def __init__(self, *, identity: Optional["_models.ManagedIdentityReference"] = N """ :keyword identity: Managed identity properties for the time series database connection resource. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :paramtype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference """ super().__init__(**kwargs) self.connection_type: Optional[str] = None @@ -72,18 +72,18 @@ class AzureDataExplorerConnectionProperties( Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar connection_type: The type of time series connection resource. Required. "AzureDataExplorer" - :vartype connection_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionType + :vartype connection_type: str or ~azure.mgmt.digitaltwins.models.ConnectionType :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", and "Disabled". :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnectionState + ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnectionState :ivar identity: Managed identity properties for the time series database connection resource. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :vartype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :ivar adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. :vartype adx_resource_id: str :ivar adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. @@ -118,7 +118,7 @@ class AzureDataExplorerConnectionProperties( this property to 'true' will generate an additional column in the property events table in ADX. Known values are: "true" and "false". :vartype record_property_and_item_removals: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.RecordPropertyAndItemRemovals + ~azure.mgmt.digitaltwins.models.RecordPropertyAndItemRemovals """ _validation = { @@ -172,7 +172,7 @@ def __init__( """ :keyword identity: Managed identity properties for the time series database connection resource. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :paramtype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :keyword adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. :paramtype adx_resource_id: str :keyword adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. @@ -207,7 +207,7 @@ def __init__( 'true'. Setting this property to 'true' will generate an additional column in the property events table in ADX. Known values are: "true" and "false". :paramtype record_property_and_item_removals: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.RecordPropertyAndItemRemovals + ~azure.mgmt.digitaltwins.models.RecordPropertyAndItemRemovals """ super().__init__(identity=identity, **kwargs) self.connection_type: str = "AzureDataExplorer" @@ -229,7 +229,7 @@ class CheckNameRequest(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Resource name. Required. :vartype name: str @@ -269,7 +269,7 @@ class CheckNameResult(_serialization.Model): :vartype message: str :ivar reason: Message providing the reason why the given name is invalid. Known values are: "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.Reason + :vartype reason: str or ~azure.mgmt.digitaltwins.models.Reason """ _attribute_map = { @@ -294,7 +294,7 @@ def __init__( :paramtype message: str :keyword reason: Message providing the reason why the given name is invalid. Known values are: "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.Reason + :paramtype reason: str or ~azure.mgmt.digitaltwins.models.Reason """ super().__init__(**kwargs) self.name_available = name_available @@ -310,14 +310,14 @@ class ConnectionProperties(_serialization.Model): :ivar provisioning_state: The provisioning state. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionPropertiesProvisioningState + ~azure.mgmt.digitaltwins.models.ConnectionPropertiesProvisioningState :ivar private_endpoint: The private endpoint. - :vartype private_endpoint: ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpoint + :vartype private_endpoint: ~azure.mgmt.digitaltwins.models.PrivateEndpoint :ivar group_ids: The list of group ids for the private endpoint connection. :vartype group_ids: list[str] :ivar private_link_service_connection_state: The connection state. :vartype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionPropertiesPrivateLinkServiceConnectionState + ~azure.mgmt.digitaltwins.models.ConnectionPropertiesPrivateLinkServiceConnectionState """ _validation = { @@ -346,12 +346,12 @@ def __init__( ) -> None: """ :keyword private_endpoint: The private endpoint. - :paramtype private_endpoint: ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpoint + :paramtype private_endpoint: ~azure.mgmt.digitaltwins.models.PrivateEndpoint :keyword group_ids: The list of group ids for the private endpoint connection. :paramtype group_ids: list[str] :keyword private_link_service_connection_state: The connection state. :paramtype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionPropertiesPrivateLinkServiceConnectionState + ~azure.mgmt.digitaltwins.models.ConnectionPropertiesPrivateLinkServiceConnectionState """ super().__init__(**kwargs) self.provisioning_state = None @@ -363,12 +363,11 @@ def __init__( class ConnectionState(_serialization.Model): """The current state of a private endpoint connection. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar status: The status of a private endpoint connection. Required. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateLinkServiceConnectionStatus + :vartype status: str or ~azure.mgmt.digitaltwins.models.PrivateLinkServiceConnectionStatus :ivar description: The description for the current state of a private endpoint connection. Required. :vartype description: str @@ -398,8 +397,7 @@ def __init__( """ :keyword status: The status of a private endpoint connection. Required. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateLinkServiceConnectionStatus + :paramtype status: str or ~azure.mgmt.digitaltwins.models.PrivateLinkServiceConnectionStatus :keyword description: The description for the current state of a private endpoint connection. Required. :paramtype description: str @@ -412,15 +410,14 @@ def __init__( self.actions_required = actions_required -class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): +class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): # pylint: disable=name-too-long """The connection state. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar status: The status of a private endpoint connection. Required. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateLinkServiceConnectionStatus + :vartype status: str or ~azure.mgmt.digitaltwins.models.PrivateLinkServiceConnectionStatus :ivar description: The description for the current state of a private endpoint connection. Required. :vartype description: str @@ -428,45 +425,13 @@ class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): :vartype actions_required: str """ - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(status=status, description=description, actions_required=actions_required, **kwargs) - class DigitalTwinsResource(_serialization.Model): """The common properties of a DigitalTwinsInstance. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The resource identifier. :vartype id: str @@ -479,10 +444,10 @@ class DigitalTwinsResource(_serialization.Model): :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentity + :vartype identity: ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentity :ivar system_data: Metadata pertaining to creation and last modification of the DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2023_01_31.models.SystemData + :vartype system_data: ~azure.mgmt.digitaltwins.models.SystemData """ _validation = { @@ -517,7 +482,7 @@ def __init__( :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentity + :paramtype identity: ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentity """ super().__init__(**kwargs) self.id = None @@ -534,7 +499,7 @@ class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The resource identifier. :vartype id: str @@ -547,10 +512,10 @@ class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentity + :vartype identity: ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentity :ivar system_data: Metadata pertaining to creation and last modification of the DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2023_01_31.models.SystemData + :vartype system_data: ~azure.mgmt.digitaltwins.models.SystemData :ivar created_time: Time when DigitalTwinsInstance was created. :vartype created_time: ~datetime.datetime :ivar last_updated_time: Time when DigitalTwinsInstance was updated. @@ -558,17 +523,15 @@ class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", and "Moving". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.ProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.digitaltwins.models.ProvisioningState :ivar host_name: Api endpoint to work with DigitalTwinsInstance. :vartype host_name: str :ivar private_endpoint_connections: The private endpoint connections. :vartype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + list[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PublicNetworkAccess + :vartype public_network_access: str or ~azure.mgmt.digitaltwins.models.PublicNetworkAccess """ _validation = { @@ -618,14 +581,13 @@ def __init__( :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentity + :paramtype identity: ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentity :keyword private_endpoint_connections: The private endpoint connections. :paramtype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + list[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PublicNetworkAccess + :paramtype public_network_access: str or ~azure.mgmt.digitaltwins.models.PublicNetworkAccess """ super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.created_time = None @@ -642,7 +604,7 @@ class DigitalTwinsDescriptionListResult(_serialization.Model): :ivar next_link: The link used to get the next page of DigitalTwins description objects. :vartype next_link: str :ivar value: A list of DigitalTwins description objects. - :vartype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] + :vartype value: list[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] """ _attribute_map = { @@ -661,7 +623,7 @@ def __init__( :keyword next_link: The link used to get the next page of DigitalTwins description objects. :paramtype next_link: str :keyword value: A list of DigitalTwins description objects. - :paramtype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] + :paramtype value: list[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] """ super().__init__(**kwargs) self.next_link = next_link @@ -680,7 +642,7 @@ class ExternalResource(_serialization.Model): :ivar type: The resource type. :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2023_01_31.models.SystemData + :vartype system_data: ~azure.mgmt.digitaltwins.models.SystemData """ _validation = { @@ -711,7 +673,7 @@ class DigitalTwinsEndpointResource(ExternalResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The resource identifier. :vartype id: str @@ -720,10 +682,9 @@ class DigitalTwinsEndpointResource(ExternalResource): :ivar type: The resource type. :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2023_01_31.models.SystemData + :vartype system_data: ~azure.mgmt.digitaltwins.models.SystemData :ivar properties: DigitalTwinsInstance endpoint resource properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResourceProperties + :vartype properties: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResourceProperties """ _validation = { @@ -745,8 +706,7 @@ class DigitalTwinsEndpointResource(ExternalResource): def __init__(self, *, properties: "_models.DigitalTwinsEndpointResourceProperties", **kwargs: Any) -> None: """ :keyword properties: DigitalTwinsInstance endpoint resource properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResourceProperties + :paramtype properties: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResourceProperties """ super().__init__(**kwargs) self.properties = properties @@ -758,7 +718,7 @@ class DigitalTwinsEndpointResourceListResult(_serialization.Model): :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. :vartype next_link: str :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] + :vartype value: list[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] """ _attribute_map = { @@ -777,8 +737,7 @@ def __init__( :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. :paramtype next_link: str :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] + :paramtype value: list[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] """ super().__init__(**kwargs) self.next_link = next_link @@ -793,16 +752,15 @@ class DigitalTwinsEndpointResourceProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointType + :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.models.EndpointType :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.digitaltwins.models.EndpointProvisioningState :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. :vartype created_time: ~datetime.datetime :ivar authentication_type: Specifies the authentication type being used for connecting to the @@ -810,15 +768,14 @@ class DigitalTwinsEndpointResourceProperties(_serialization.Model): specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :vartype dead_letter_secret: str :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. :vartype dead_letter_uri: str :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :vartype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference """ _validation = { @@ -854,15 +811,14 @@ def __init__( specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :paramtype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :paramtype dead_letter_secret: str :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. :paramtype dead_letter_uri: str :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :paramtype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference """ super().__init__(**kwargs) self.endpoint_type: Optional[str] = None @@ -881,7 +837,7 @@ class DigitalTwinsIdentity(_serialization.Model): :ivar type: The type of Managed Identity used by the DigitalTwinsInstance. Known values are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentityType + :vartype type: str or ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a systemAssigned(implicit) identity. @@ -892,10 +848,10 @@ class DigitalTwinsIdentity(_serialization.Model): :vartype tenant_id: str :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long . :vartype user_assigned_identities: dict[str, - ~azure.mgmt.digitaltwins.v2023_01_31.models.UserAssignedIdentity] + ~azure.mgmt.digitaltwins.models.UserAssignedIdentity] """ _validation = { @@ -920,13 +876,13 @@ def __init__( """ :keyword type: The type of Managed Identity used by the DigitalTwinsInstance. Known values are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentityType + :paramtype type: str or ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long . :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.digitaltwins.v2023_01_31.models.UserAssignedIdentity] + ~azure.mgmt.digitaltwins.models.UserAssignedIdentity] """ super().__init__(**kwargs) self.type = type @@ -941,9 +897,9 @@ class DigitalTwinsPatchDescription(_serialization.Model): :ivar tags: Instance patch properties. :vartype tags: dict[str, str] :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentity + :vartype identity: ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentity :ivar properties: Properties for the DigitalTwinsInstance. - :vartype properties: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsPatchProperties + :vartype properties: ~azure.mgmt.digitaltwins.models.DigitalTwinsPatchProperties """ _attribute_map = { @@ -964,9 +920,9 @@ def __init__( :keyword tags: Instance patch properties. :paramtype tags: dict[str, str] :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsIdentity + :paramtype identity: ~azure.mgmt.digitaltwins.models.DigitalTwinsIdentity :keyword properties: Properties for the DigitalTwinsInstance. - :paramtype properties: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsPatchProperties + :paramtype properties: ~azure.mgmt.digitaltwins.models.DigitalTwinsPatchProperties """ super().__init__(**kwargs) self.tags = tags @@ -979,8 +935,7 @@ class DigitalTwinsPatchProperties(_serialization.Model): :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PublicNetworkAccess + :vartype public_network_access: str or ~azure.mgmt.digitaltwins.models.PublicNetworkAccess """ _attribute_map = { @@ -993,8 +948,7 @@ def __init__( """ :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.PublicNetworkAccess + :paramtype public_network_access: str or ~azure.mgmt.digitaltwins.models.PublicNetworkAccess """ super().__init__(**kwargs) self.public_network_access = public_network_access @@ -1010,7 +964,7 @@ class ErrorDefinition(_serialization.Model): :ivar message: Description of the error. :vartype message: str :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2023_01_31.models.ErrorDefinition] + :vartype details: list[~azure.mgmt.digitaltwins.models.ErrorDefinition] """ _validation = { @@ -1037,7 +991,7 @@ class ErrorResponse(_serialization.Model): """Error response. :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2023_01_31.models.ErrorDefinition + :vartype error: ~azure.mgmt.digitaltwins.models.ErrorDefinition """ _attribute_map = { @@ -1047,7 +1001,7 @@ class ErrorResponse(_serialization.Model): def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: """ :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2023_01_31.models.ErrorDefinition + :paramtype error: ~azure.mgmt.digitaltwins.models.ErrorDefinition """ super().__init__(**kwargs) self.error = error @@ -1058,16 +1012,15 @@ class EventGrid(DigitalTwinsEndpointResourceProperties): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointType + :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.models.EndpointType :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.digitaltwins.models.EndpointProvisioningState :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. :vartype created_time: ~datetime.datetime :ivar authentication_type: Specifies the authentication type being used for connecting to the @@ -1075,15 +1028,14 @@ class EventGrid(DigitalTwinsEndpointResourceProperties): specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :vartype dead_letter_secret: str :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. :vartype dead_letter_uri: str :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :vartype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :ivar topic_endpoint: EventGrid Topic Endpoint. Required. :vartype topic_endpoint: str :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. @@ -1131,15 +1083,14 @@ def __init__( specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :paramtype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :paramtype dead_letter_secret: str :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. :paramtype dead_letter_uri: str :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :paramtype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :keyword topic_endpoint: EventGrid Topic Endpoint. Required. :paramtype topic_endpoint: str :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. @@ -1165,16 +1116,15 @@ class EventHub(DigitalTwinsEndpointResourceProperties): # pylint: disable=too-m Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointType + :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.models.EndpointType :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.digitaltwins.models.EndpointProvisioningState :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. :vartype created_time: ~datetime.datetime :ivar authentication_type: Specifies the authentication type being used for connecting to the @@ -1182,15 +1132,14 @@ class EventHub(DigitalTwinsEndpointResourceProperties): # pylint: disable=too-m specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :vartype dead_letter_secret: str :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. :vartype dead_letter_uri: str :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :vartype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. :vartype connection_string_primary_key: str @@ -1244,15 +1193,14 @@ def __init__( specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :paramtype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :paramtype dead_letter_secret: str :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. :paramtype dead_letter_uri: str :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :paramtype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. :paramtype connection_string_primary_key: str @@ -1285,10 +1233,10 @@ class GroupIdInformation(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar properties: The group information properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformationProperties + :vartype properties: ~azure.mgmt.digitaltwins.models.GroupIdInformationProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The resource name. @@ -1319,7 +1267,7 @@ def __init__( ) -> None: """ :keyword properties: The group information properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformationProperties + :paramtype properties: ~azure.mgmt.digitaltwins.models.GroupIdInformationProperties :keyword id: The resource identifier. :paramtype id: str """ @@ -1373,7 +1321,7 @@ class GroupIdInformationResponse(_serialization.Model): """The available private link resources for a Digital Twin. :ivar value: The list of available private link resources for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformation] + :vartype value: list[~azure.mgmt.digitaltwins.models.GroupIdInformation] """ _attribute_map = { @@ -1383,7 +1331,7 @@ class GroupIdInformationResponse(_serialization.Model): def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of available private link resources for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformation] + :paramtype value: list[~azure.mgmt.digitaltwins.models.GroupIdInformation] """ super().__init__(**kwargs) self.value = value @@ -1394,7 +1342,7 @@ class ManagedIdentityReference(_serialization.Model): :ivar type: The type of managed identity used. Known values are: "SystemAssigned" and "UserAssigned". - :vartype type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.IdentityType + :vartype type: str or ~azure.mgmt.digitaltwins.models.IdentityType :ivar user_assigned_identity: The user identity ARM resource id if the managed identity type is 'UserAssigned'. :vartype user_assigned_identity: str @@ -1415,7 +1363,7 @@ def __init__( """ :keyword type: The type of managed identity used. Known values are: "SystemAssigned" and "UserAssigned". - :paramtype type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.IdentityType + :paramtype type: str or ~azure.mgmt.digitaltwins.models.IdentityType :keyword user_assigned_identity: The user identity ARM resource id if the managed identity type is 'UserAssigned'. :paramtype user_assigned_identity: str @@ -1433,7 +1381,7 @@ class Operation(_serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2023_01_31.models.OperationDisplay + :vartype display: ~azure.mgmt.digitaltwins.models.OperationDisplay :ivar origin: The intended executor of the operation. :vartype origin: str :ivar is_data_action: If the operation is a data action (for data plane rbac). @@ -1460,7 +1408,7 @@ class Operation(_serialization.Model): def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: """ :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2023_01_31.models.OperationDisplay + :paramtype display: ~azure.mgmt.digitaltwins.models.OperationDisplay """ super().__init__(**kwargs) self.name = None @@ -1518,7 +1466,7 @@ class OperationListResult(_serialization.Model): :vartype next_link: str :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.Operation] + :vartype value: list[~azure.mgmt.digitaltwins.models.Operation] """ _validation = { @@ -1568,7 +1516,7 @@ class PrivateEndpointConnection(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The resource identifier. :vartype id: str @@ -1577,10 +1525,10 @@ class PrivateEndpointConnection(_serialization.Model): :ivar type: The resource type. :vartype type: str :ivar properties: The connection properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionProperties + :vartype properties: ~azure.mgmt.digitaltwins.models.ConnectionProperties :ivar system_data: Metadata pertaining to creation and last modification of the private endpoint connection. - :vartype system_data: ~azure.mgmt.digitaltwins.v2023_01_31.models.SystemData + :vartype system_data: ~azure.mgmt.digitaltwins.models.SystemData """ _validation = { @@ -1602,7 +1550,7 @@ class PrivateEndpointConnection(_serialization.Model): def __init__(self, *, properties: "_models.ConnectionProperties", **kwargs: Any) -> None: """ :keyword properties: The connection properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2023_01_31.models.ConnectionProperties + :paramtype properties: ~azure.mgmt.digitaltwins.models.ConnectionProperties """ super().__init__(**kwargs) self.id = None @@ -1616,7 +1564,7 @@ class PrivateEndpointConnectionsResponse(_serialization.Model): """The available private link connections for a Digital Twin. :ivar value: The list of available private link connections for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + :vartype value: list[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] """ _attribute_map = { @@ -1626,7 +1574,7 @@ class PrivateEndpointConnectionsResponse(_serialization.Model): def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of available private link connections for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + :paramtype value: list[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] """ super().__init__(**kwargs) self.value = value @@ -1637,16 +1585,15 @@ class ServiceBus(DigitalTwinsEndpointResourceProperties): # pylint: disable=too Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointType + :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.models.EndpointType :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.EndpointProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.digitaltwins.models.EndpointProvisioningState :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. :vartype created_time: ~datetime.datetime :ivar authentication_type: Specifies the authentication type being used for connecting to the @@ -1654,15 +1601,14 @@ class ServiceBus(DigitalTwinsEndpointResourceProperties): # pylint: disable=too specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :vartype dead_letter_secret: str :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. :vartype dead_letter_uri: str :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :vartype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :ivar primary_connection_string: PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. :vartype primary_connection_string: str @@ -1715,15 +1661,14 @@ def __init__( specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.AuthenticationType + :paramtype authentication_type: str or ~azure.mgmt.digitaltwins.models.AuthenticationType :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be obfuscated during read. :paramtype dead_letter_secret: str :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. :paramtype dead_letter_uri: str :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2023_01_31.models.ManagedIdentityReference + :paramtype identity: ~azure.mgmt.digitaltwins.models.ManagedIdentityReference :keyword primary_connection_string: PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. :paramtype primary_connection_string: str @@ -1757,15 +1702,14 @@ class SystemData(_serialization.Model): :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.CreatedByType + :vartype created_by_type: str or ~azure.mgmt.digitaltwins.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.CreatedByType + :vartype last_modified_by_type: str or ~azure.mgmt.digitaltwins.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ @@ -1795,15 +1739,14 @@ def __init__( :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.digitaltwins.v2023_01_31.models.CreatedByType + :paramtype created_by_type: str or ~azure.mgmt.digitaltwins.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.CreatedByType + :paramtype last_modified_by_type: str or ~azure.mgmt.digitaltwins.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ @@ -1828,10 +1771,9 @@ class TimeSeriesDatabaseConnection(ExternalResource): :ivar type: The resource type. :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2023_01_31.models.SystemData + :vartype system_data: ~azure.mgmt.digitaltwins.models.SystemData :ivar properties: Properties of a specific time series database connection. - :vartype properties: - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnectionProperties + :vartype properties: ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnectionProperties """ _validation = { @@ -1854,8 +1796,7 @@ def __init__( ) -> None: """ :keyword properties: Properties of a specific time series database connection. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnectionProperties + :paramtype properties: ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnectionProperties """ super().__init__(**kwargs) self.properties = properties @@ -1867,7 +1808,7 @@ class TimeSeriesDatabaseConnectionListResult(_serialization.Model): :ivar next_link: The link used to get the next page of results. :vartype next_link: str :ivar value: A list of time series database connection resources. - :vartype value: list[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + :vartype value: list[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] """ _attribute_map = { @@ -1886,8 +1827,7 @@ def __init__( :keyword next_link: The link used to get the next page of results. :paramtype next_link: str :keyword value: A list of time series database connection resources. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + :paramtype value: list[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] """ super().__init__(**kwargs) self.next_link = next_link diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_patch.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_patch.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/models/_patch.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/__init__.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/__init__.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/__init__.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_digital_twins_endpoint_operations.py similarity index 71% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_digital_twins_endpoint_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_digital_twins_endpoint_operations.py index 910e164ca2df..8551fa11b85a 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_digital_twins_endpoint_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_digital_twins_endpoint_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,26 +17,26 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +73,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +121,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,7 +138,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +170,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +189,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +220,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -236,7 +237,7 @@ class DigitalTwinsEndpointOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient`'s :attr:`digital_twins_endpoint` attribute. """ @@ -260,20 +261,19 @@ def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,17 +284,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -306,13 +304,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DigitalTwinsEndpointResourceListResult", pipeline_response) @@ -322,10 +319,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -338,10 +336,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - @distributed_trace def get( self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any @@ -355,12 +349,11 @@ def get( :type resource_name: str :param endpoint_name: Name of Endpoint Resource. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource + :rtype: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,24 +364,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -398,26 +390,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], + endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO[bytes]], **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -428,19 +416,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(endpoint_description, (IO, bytes)): + if isinstance(endpoint_description, (IOBase, bytes)): _content = endpoint_description else: _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, endpoint_name=endpoint_name, @@ -449,39 +437,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - @overload def begin_create_or_update( self, @@ -504,23 +488,14 @@ def begin_create_or_update( :type endpoint_name: str :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource + :type endpoint_description: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -530,7 +505,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, endpoint_name: str, - endpoint_description: IO, + endpoint_description: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -546,22 +521,14 @@ def begin_create_or_update( :type endpoint_name: str :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. Required. - :type endpoint_description: IO + :type endpoint_description: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -571,7 +538,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], + endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DigitalTwinsEndpointResource]: """Create or update DigitalTwinsInstance endpoint. @@ -584,30 +551,19 @@ def begin_create_or_update( :param endpoint_name: Name of Endpoint Resource. Required. :type endpoint_name: str :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + Is either a DigitalTwinsEndpointResource type or a IO[bytes] type. Required. + :type endpoint_description: ~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource or + IO[bytes] :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -626,12 +582,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -641,22 +598,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DigitalTwinsEndpointResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return LROPoller[_models.DigitalTwinsEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -667,48 +622,43 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -723,24 +673,16 @@ def begin_delete( :type resource_name: str :param endpoint_name: Name of Endpoint Resource. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsEndpointResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -756,12 +698,13 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) + deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -771,14 +714,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DigitalTwinsEndpointResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } + return LROPoller[_models.DigitalTwinsEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_digital_twins_operations.py similarity index 70% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_digital_twins_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_digital_twins_operations.py index 0507006b2376..aa2d1ef0ef65 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_digital_twins_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_digital_twins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,26 +17,26 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +59,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceName": _SERIALIZER.url( "resource_name", @@ -70,7 +71,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +88,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +100,7 @@ def build_create_or_update_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceName": _SERIALIZER.url( "resource_name", @@ -111,7 +112,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +131,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -142,7 +143,7 @@ def build_update_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceName": _SERIALIZER.url( "resource_name", @@ -154,7 +155,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +174,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -184,7 +185,7 @@ def build_delete_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceName": _SERIALIZER.url( "resource_name", @@ -196,7 +197,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,7 +212,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -222,7 +223,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -237,7 +238,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -248,11 +249,11 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -267,7 +268,7 @@ def build_check_name_availability_request(location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -281,7 +282,7 @@ def build_check_name_availability_request(location: str, subscription_id: str, * "location": _SERIALIZER.url("location", location, "str", min_length=3), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -300,7 +301,7 @@ class DigitalTwinsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_10_31.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient`'s :attr:`digital_twins` attribute. """ @@ -322,12 +323,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :rtype: ~azure.mgmt.digitaltwins.models.DigitalTwinsDescription :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,23 +338,22 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,25 +363,21 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], + digital_twins_create: Union[_models.DigitalTwinsDescription, IO[bytes]], **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,19 +388,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(digital_twins_create, (IO, bytes)): + if isinstance(digital_twins_create, (IOBase, bytes)): _content = digital_twins_create else: _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -413,39 +408,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - @overload def begin_create_or_update( self, @@ -466,22 +457,13 @@ def begin_create_or_update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :type digital_twins_create: ~azure.mgmt.digitaltwins.models.DigitalTwinsDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -490,7 +472,7 @@ def begin_create_or_update( self, resource_group_name: str, resource_name: str, - digital_twins_create: IO, + digital_twins_create: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -505,22 +487,13 @@ def begin_create_or_update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO + :type digital_twins_create: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -529,7 +502,7 @@ def begin_create_or_update( self, resource_group_name: str, resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], + digital_twins_create: Union[_models.DigitalTwinsDescription, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DigitalTwinsDescription]: """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property @@ -542,30 +515,18 @@ def begin_create_or_update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + DigitalTwinsDescription type or a IO[bytes] type. Required. + :type digital_twins_create: ~azure.mgmt.digitaltwins.models.DigitalTwinsDescription or + IO[bytes] :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -583,12 +544,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -598,20 +560,85 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DigitalTwinsDescription].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.DigitalTwinsDescription]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(digital_twins_patch_description, (IOBase, bytes)): + _content = digital_twins_patch_description + else: + _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def update( + def begin_update( self, resource_group_name: str, resource_name: str, @@ -619,7 +646,7 @@ def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DigitalTwinsDescription: + ) -> LROPoller[_models.DigitalTwinsDescription]: """Update metadata of DigitalTwinsInstance. :param resource_group_name: The name of the resource group that contains the @@ -630,26 +657,26 @@ def update( :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Required. :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsPatchDescription + ~azure.mgmt.digitaltwins.models.DigitalTwinsPatchDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def begin_update( self, resource_group_name: str, resource_name: str, - digital_twins_patch_description: IO, + digital_twins_patch_description: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DigitalTwinsDescription: + ) -> LROPoller[_models.DigitalTwinsDescription]: """Update metadata of DigitalTwinsInstance. :param resource_group_name: The name of the resource group that contains the @@ -659,24 +686,24 @@ def update( :type resource_name: str :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_patch_description: IO + :type digital_twins_patch_description: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def begin_update( self, resource_group_name: str, resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], + digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO[bytes]], **kwargs: Any - ) -> _models.DigitalTwinsDescription: + ) -> LROPoller[_models.DigitalTwinsDescription]: """Update metadata of DigitalTwinsInstance. :param resource_group_name: The name of the resource group that contains the @@ -685,81 +712,63 @@ def update( :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. + either a DigitalTwinsPatchDescription type or a IO[bytes] type. Required. :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription + ~azure.mgmt.digitaltwins.models.DigitalTwinsPatchDescription or IO[bytes] + :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + digital_twins_patch_description=digital_twins_patch_description, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DigitalTwinsDescription].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DigitalTwinsDescription]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { + def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -770,47 +779,42 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -823,24 +827,15 @@ def begin_delete( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -855,12 +850,13 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) + deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -870,36 +866,32 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DigitalTwinsDescription].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } + return LROPoller[_models.DigitalTwinsDescription]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -910,15 +902,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -930,13 +920,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DigitalTwinsDescriptionListResult", pipeline_response) @@ -946,10 +935,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -962,8 +952,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -973,20 +961,18 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the DigitalTwinsInstance. Required. :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 DigitalTwinsDescription or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.models.DigitalTwinsDescription] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,16 +983,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1018,13 +1002,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DigitalTwinsDescriptionListResult", pipeline_response) @@ -1034,10 +1017,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1050,10 +1034,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - } - @overload def check_name_availability( self, @@ -1070,14 +1050,12 @@ def check_name_availability( :param digital_twins_instance_check_name: Set the name parameter in the DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameRequest + :type digital_twins_instance_check_name: ~azure.mgmt.digitaltwins.models.CheckNameRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameResult + :rtype: ~azure.mgmt.digitaltwins.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1085,7 +1063,7 @@ def check_name_availability( def check_name_availability( self, location: str, - digital_twins_instance_check_name: IO, + digital_twins_instance_check_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1097,19 +1075,21 @@ def check_name_availability( :param digital_twins_instance_check_name: Set the name parameter in the DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Required. - :type digital_twins_instance_check_name: IO + :type digital_twins_instance_check_name: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameResult + :rtype: ~azure.mgmt.digitaltwins.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any + self, + location: str, + digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameResult: """Check if a DigitalTwinsInstance name is available. @@ -1117,18 +1097,14 @@ def check_name_availability( :type location: str :param digital_twins_instance_check_name: Set the name parameter in the DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + either a CheckNameRequest type or a IO[bytes] type. Required. + :type digital_twins_instance_check_name: ~azure.mgmt.digitaltwins.models.CheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.CheckNameResult + :rtype: ~azure.mgmt.digitaltwins.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1139,34 +1115,33 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): + if isinstance(digital_twins_instance_check_name, (IOBase, bytes)): _content = digital_twins_instance_check_name else: _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1176,13 +1151,9 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_operations.py similarity index 77% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_operations.py index b37c7c526e0e..52803c83775d 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +64,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient`'s :attr:`operations` attribute. """ @@ -83,18 +81,17 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.Operation] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -124,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return 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) @@ -140,10 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_patch.py similarity index 100% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_patch.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_patch.py diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_private_endpoint_connections_operations.py similarity index 71% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_private_endpoint_connections_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_private_endpoint_connections_operations.py index 05bfdb6015a1..d989a1941ab8 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_private_endpoint_connections_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,25 +16,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +71,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -138,7 +139,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +165,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,7 +186,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +213,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +232,7 @@ class PrivateEndpointConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient`'s :attr:`private_endpoint_connections` attribute. """ @@ -255,12 +256,11 @@ def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnectionsResponse + :rtype: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnectionsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,23 +271,22 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -297,16 +296,12 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } + return deserialized # type: ignore @distributed_trace def get( @@ -321,12 +316,11 @@ def get( :type resource_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection + :rtype: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,24 +331,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,21 +357,17 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,39 +378,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -436,14 +429,6 @@ def begin_delete( :type resource_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -451,13 +436,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -467,11 +452,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -480,27 +466,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,19 +493,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -532,39 +514,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create_or_update( self, @@ -587,23 +565,14 @@ def begin_create_or_update( :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection + :type private_endpoint_connection: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -613,7 +582,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: IO, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -629,22 +598,14 @@ def begin_create_or_update( :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. Required. - :type private_endpoint_connection: IO + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -654,7 +615,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the status of a private endpoint connection with the given name. @@ -667,30 +628,19 @@ def begin_create_or_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type private_endpoint_connection: ~azure.mgmt.digitaltwins.models.PrivateEndpointConnection or + IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -709,12 +659,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -724,14 +675,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_private_link_resources_operations.py similarity index 76% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_private_link_resources_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_private_link_resources_operations.py index 122c146169ba..f024f0564386 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_private_link_resources_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +66,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +107,7 @@ def build_get_request( "resourceId": _SERIALIZER.url("resource_id", resource_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +124,7 @@ class PrivateLinkResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient`'s :attr:`private_link_resources` attribute. """ @@ -148,12 +146,11 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformationResponse + :rtype: ~azure.mgmt.digitaltwins.models.GroupIdInformationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -164,23 +161,22 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,16 +186,12 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) + deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } + return deserialized # type: ignore @distributed_trace def get( @@ -214,12 +206,11 @@ def get( :type resource_name: str :param resource_id: The name of the private link resource. Required. :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformation + :rtype: ~azure.mgmt.digitaltwins.models.GroupIdInformation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,24 +221,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, resource_id=resource_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,13 +247,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupIdInformation", pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } + return deserialized # type: ignore diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_time_series_database_connections_operations.py similarity index 73% rename from sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_time_series_database_connections_operations.py rename to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_time_series_database_connections_operations.py index c1e820b02dd1..9cfcf2de7353 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_time_series_database_connections_operations.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/operations/_time_series_database_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,26 +17,26 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._serialization import Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +73,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +125,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +146,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -177,7 +178,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +203,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +234,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -254,7 +255,7 @@ class TimeSeriesDatabaseConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.AzureDigitalTwinsManagementClient`'s + :class:`~azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient`'s :attr:`time_series_database_connections` attribute. """ @@ -278,20 +279,19 @@ def list( :type resource_group_name: str :param resource_name: The name of the DigitalTwinsInstance. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,17 +302,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -324,13 +322,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("TimeSeriesDatabaseConnectionListResult", pipeline_response) @@ -340,10 +337,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,10 +354,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - @distributed_trace def get( self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any @@ -373,12 +367,11 @@ def get( :type resource_name: str :param time_series_database_connection_name: Name of time series database connection. Required. :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection + :rtype: ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,24 +382,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, time_series_database_connection_name=time_series_database_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -416,26 +408,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], + time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO[bytes]], **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,19 +434,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): + if isinstance(time_series_database_connection_description, (IOBase, bytes)): _content = time_series_database_connection_description else: _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, time_series_database_connection_name=time_series_database_connection_name, @@ -467,39 +455,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - @overload def begin_create_or_update( self, @@ -523,22 +507,14 @@ def begin_create_or_update( :param time_series_database_connection_description: The time series database connection description. Required. :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection + ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -548,7 +524,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, time_series_database_connection_name: str, - time_series_database_connection_description: IO, + time_series_database_connection_description: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -564,22 +540,14 @@ def begin_create_or_update( :type time_series_database_connection_name: str :param time_series_database_connection_description: The time series database connection description. Required. - :type time_series_database_connection_description: IO + :type time_series_database_connection_description: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -589,7 +557,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], + time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: """Create or update a time series database connection. @@ -602,30 +570,19 @@ def begin_create_or_update( :param time_series_database_connection_name: Name of time series database connection. Required. :type time_series_database_connection_name: str :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. + description. Is either a TimeSeriesDatabaseConnection type or a IO[bytes] type. Required. :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection or IO[bytes] :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -644,12 +601,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -659,17 +617,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.TimeSeriesDatabaseConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return LROPoller[_models.TimeSeriesDatabaseConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, @@ -678,8 +634,8 @@ def _delete_initial( time_series_database_connection_name: str, cleanup_connection_artifacts: Optional[Union[str, _models.CleanupConnectionArtifacts]] = None, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -690,49 +646,44 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, time_series_database_connection_name=time_series_database_connection_name, subscription_id=self._config.subscription_id, cleanup_connection_artifacts=cleanup_connection_artifacts, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -758,25 +709,17 @@ def begin_delete( 'true' does not delete any recorded data. Known values are: "true" and "false". Default value is None. :type cleanup_connection_artifacts: str or - ~azure.mgmt.digitaltwins.v2023_01_31.models.CleanupConnectionArtifacts - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.digitaltwins.models.CleanupConnectionArtifacts :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.TimeSeriesDatabaseConnection] + ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.models.TimeSeriesDatabaseConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -793,12 +736,13 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) + deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -808,14 +752,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.TimeSeriesDatabaseConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } + return LROPoller[_models.TimeSeriesDatabaseConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_azure_digital_twins_management_client.py deleted file mode 100644 index 27973d5538ac..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,101 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import DigitalTwinsEndpointOperations, DigitalTwinsOperations, Operations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2020_03_01_preview.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_configuration.py deleted file mode 100644 index ec39bf7f644a..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-03-01-preview"] = kwargs.pop("api_version", "2020-03-01-preview") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_metadata.json deleted file mode 100644 index 31bc748f4816..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2020-03-01-preview", - "total_api_version_list": ["2020-03-01-preview"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index f73b6d5bc06d..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,101 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import DigitalTwinsEndpointOperations, DigitalTwinsOperations, Operations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2020_03_01_preview.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2020_03_01_preview.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2020_03_01_preview.aio.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_configuration.py deleted file mode 100644 index 5debe005e234..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-03-01-preview"] = kwargs.pop("api_version", "2020-03-01-preview") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/__init__.py deleted file mode 100644 index a2f402ab0c76..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index f22bfa6f7623..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,609 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_endpoint_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_03_01_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_digital_twins_operations.py deleted file mode 100644 index f18fe62bb183..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1045 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_operations import ( - build_check_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, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_03_01_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_operations.py deleted file mode 100644 index 3b829ac1ab38..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,140 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_03_01_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/__init__.py deleted file mode 100644 index b8f3dc91ee16..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/__init__.py +++ /dev/null @@ -1,65 +0,0 @@ -# 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 CheckNameRequest -from ._models_py3 import CheckNameResult -from ._models_py3 import DigitalTwinsDescription -from ._models_py3 import DigitalTwinsDescriptionListResult -from ._models_py3 import DigitalTwinsEndpointResource -from ._models_py3 import DigitalTwinsEndpointResourceListResult -from ._models_py3 import DigitalTwinsEndpointResourceProperties -from ._models_py3 import DigitalTwinsPatchDescription -from ._models_py3 import DigitalTwinsResource -from ._models_py3 import DigitalTwinsSkuInfo -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorResponse -from ._models_py3 import EventGrid -from ._models_py3 import EventHub -from ._models_py3 import ExternalResource -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import ServiceBus - -from ._azure_digital_twins_management_client_enums import DigitalTwinsSku -from ._azure_digital_twins_management_client_enums import EndpointProvisioningState -from ._azure_digital_twins_management_client_enums import EndpointType -from ._azure_digital_twins_management_client_enums import ProvisioningState -from ._azure_digital_twins_management_client_enums import Reason -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CheckNameRequest", - "CheckNameResult", - "DigitalTwinsDescription", - "DigitalTwinsDescriptionListResult", - "DigitalTwinsEndpointResource", - "DigitalTwinsEndpointResourceListResult", - "DigitalTwinsEndpointResourceProperties", - "DigitalTwinsPatchDescription", - "DigitalTwinsResource", - "DigitalTwinsSkuInfo", - "ErrorDefinition", - "ErrorResponse", - "EventGrid", - "EventHub", - "ExternalResource", - "Operation", - "OperationDisplay", - "OperationListResult", - "ServiceBus", - "DigitalTwinsSku", - "EndpointProvisioningState", - "EndpointType", - "ProvisioningState", - "Reason", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_azure_digital_twins_management_client_enums.py deleted file mode 100644 index 7d58368fe69b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_azure_digital_twins_management_client_enums.py +++ /dev/null @@ -1,51 +0,0 @@ -# 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 azure.core import CaseInsensitiveEnumMeta - - -class DigitalTwinsSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The name of the SKU.""" - - F1 = "F1" - - -class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - - -class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Digital Twins endpoint.""" - - EVENT_HUB = "EventHub" - EVENT_GRID = "EventGrid" - SERVICE_BUS = "ServiceBus" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - - -class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Message providing the reason why the given name is invalid.""" - - INVALID = "Invalid" - ALREADY_EXISTS = "AlreadyExists" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_models_py3.py deleted file mode 100644 index 05deaf500057..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/models/_models_py3.py +++ /dev/null @@ -1,836 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CheckNameRequest(_serialization.Model): - """The result returned from a database check name availability request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. Required. - :vartype name: str - :ivar type: The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. - Required. Default value is "Microsoft.DigitalTwins/digitalTwinsInstances". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.DigitalTwins/digitalTwinsInstances" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Resource name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameResult(_serialization.Model): - """The result returned from a check name availability request. - - :ivar name_available: Specifies a Boolean value that indicates if the name is available. - :vartype name_available: bool - :ivar name: The name that was checked. - :vartype name: str - :ivar message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.Reason - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - name: Optional[str] = None, - message: Optional[str] = None, - reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Specifies a Boolean value that indicates if the name is available. - :paramtype name_available: bool - :keyword name: The name that was checked. - :paramtype name: str - :keyword message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.Reason - """ - super().__init__(**kwargs) - self.name_available = name_available - self.name = name - self.message = message - self.reason = reason - - -class DigitalTwinsResource(_serialization.Model): - """The common properties of a DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar sku: This property is reserved for future use, and will be ignored/omitted. - :vartype sku: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsSkuInfo - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DigitalTwinsSkuInfo"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DigitalTwinsSkuInfo"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword sku: This property is reserved for future use, and will be ignored/omitted. - :paramtype sku: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsSkuInfo - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.sku = sku - - -class DigitalTwinsDescription(DigitalTwinsResource): - """The description of the DigitalTwins service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar sku: This property is reserved for future use, and will be ignored/omitted. - :vartype sku: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsSkuInfo - :ivar created_time: Time when DigitalTwinsInstance was created. - :vartype created_time: ~datetime.datetime - :ivar last_updated_time: Time when DigitalTwinsInstance was created. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.ProvisioningState - :ivar host_name: Api endpoint to work with DigitalTwinsInstance. - :vartype host_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "location": {"required": True}, - "created_time": {"readonly": True}, - "last_updated_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "host_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DigitalTwinsSkuInfo"}, - "created_time": {"key": "properties.createdTime", "type": "iso-8601"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DigitalTwinsSkuInfo"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword sku: This property is reserved for future use, and will be ignored/omitted. - :paramtype sku: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsSkuInfo - """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.created_time = None - self.last_updated_time = None - self.provisioning_state = None - self.host_name = None - - -class DigitalTwinsDescriptionListResult(_serialization.Model): - """A list of DigitalTwins description objects with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins description objects. - :vartype value: - list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsDescription]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsDescription"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - :keyword value: A list of DigitalTwins description objects. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class ExternalResource(_serialization.Model): - """Definition of a Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DigitalTwinsEndpointResource(ExternalResource): - """DigitalTwinsInstance endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: DigitalTwinsInstance endpoint resource properties. - :vartype properties: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "DigitalTwinsEndpointResourceProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.DigitalTwinsEndpointResourceProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: DigitalTwinsInstance endpoint resource properties. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class DigitalTwinsEndpointResourceListResult(_serialization.Model): - """A list of DigitalTwinsInstance Endpoints with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :vartype next_link: str - :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: - list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsEndpointResource]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsEndpointResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :paramtype next_link: str - :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class DigitalTwinsEndpointResourceProperties(_serialization.Model): - """Properties related to Digital Twins Endpoint. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventGrid, EventHub, ServiceBus - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - _subtype_map = {"endpoint_type": {"EventGrid": "EventGrid", "EventHub": "EventHub", "ServiceBus": "ServiceBus"}} - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.endpoint_type: Optional[str] = None - self.provisioning_state = None - self.created_time = None - self.tags = tags - - -class DigitalTwinsPatchDescription(_serialization.Model): - """The description of the DigitalTwins service. - - :ivar tags: Instance tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Instance tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class DigitalTwinsSkuInfo(_serialization.Model): - """Information about the SKU of the DigitalTwinsInstance. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SKU. Required. "F1" - :vartype name: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsSku - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.DigitalTwinsSku"], **kwargs: Any) -> None: - """ - :keyword name: The name of the SKU. Required. "F1" - :paramtype name: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsSku - """ - super().__init__(**kwargs) - self.name = name - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.ErrorDefinition] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class EventGrid(DigitalTwinsEndpointResourceProperties): - """properties related to eventgrid. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar topic_endpoint: EventGrid Topic Endpoint. - :vartype topic_endpoint: str - :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key1: str - :ivar access_key2: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key2: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "access_key1": {"required": True}, - "access_key2": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "tags": {"key": "tags", "type": "{str}"}, - "topic_endpoint": {"key": "TopicEndpoint", "type": "str"}, - "access_key1": {"key": "accessKey1", "type": "str"}, - "access_key2": {"key": "accessKey2", "type": "str"}, - } - - def __init__( - self, - *, - access_key1: str, - access_key2: str, - tags: Optional[Dict[str, str]] = None, - topic_endpoint: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword topic_endpoint: EventGrid Topic Endpoint. - :paramtype topic_endpoint: str - :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key1: str - :keyword access_key2: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key2: str - """ - super().__init__(tags=tags, **kwargs) - self.endpoint_type: str = "EventGrid" - self.topic_endpoint = topic_endpoint - self.access_key1 = access_key1 - self.access_key2 = access_key2 - - -class EventHub(DigitalTwinsEndpointResourceProperties): - """properties related to eventhub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :vartype connection_string_primary_key: str - :ivar connection_string_secondary_key: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :vartype connection_string_secondary_key: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "connection_string_primary_key": {"required": True}, - "connection_string_secondary_key": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "tags": {"key": "tags", "type": "{str}"}, - "connection_string_primary_key": {"key": "connectionString-PrimaryKey", "type": "str"}, - "connection_string_secondary_key": {"key": "connectionString-SecondaryKey", "type": "str"}, - } - - def __init__( - self, - *, - connection_string_primary_key: str, - connection_string_secondary_key: str, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :paramtype connection_string_primary_key: str - :keyword connection_string_secondary_key: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :paramtype connection_string_secondary_key: str - """ - super().__init__(tags=tags, **kwargs) - self.endpoint_type: str = "EventHub" - self.connection_string_primary_key = connection_string_primary_key - self.connection_string_secondary_key = connection_string_secondary_key - - -class Operation(_serialization.Model): - """DigitalTwins service REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. - :vartype name: str - :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.OperationDisplay - """ - - _validation = { - "name": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.display = display - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft DigitalTwins. - :vartype provider: str - :ivar resource: Resource Type: DigitalTwinsInstances. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Friendly description for the operation,. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of DigitalTwins 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 next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource - provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.Operation] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = None - - -class ServiceBus(DigitalTwinsEndpointResourceProperties): - """properties related to servicebus. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar primary_connection_string: PrimaryConnectionString of the endpoint. Will be obfuscated - during read. Required. - :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :vartype secondary_connection_string: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "primary_connection_string": {"required": True}, - "secondary_connection_string": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "tags": {"key": "tags", "type": "{str}"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - } - - def __init__( - self, - *, - primary_connection_string: str, - secondary_connection_string: str, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword primary_connection_string: PrimaryConnectionString of the endpoint. Will be obfuscated - during read. Required. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :paramtype secondary_connection_string: str - """ - super().__init__(tags=tags, **kwargs) - self.endpoint_type: str = "ServiceBus" - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/__init__.py deleted file mode 100644 index a2f402ab0c76..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index d26ff10113c2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,758 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, resource_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - "endpointName": _SERIALIZER.url( - "endpoint_name", endpoint_name, "str", max_length=64, min_length=1, pattern=r"^[A-Za-z0-9-._]{1,64}$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - "endpointName": _SERIALIZER.url( - "endpoint_name", endpoint_name, "str", max_length=64, min_length=1, pattern=r"^[A-Za-z0-9-._]{1,64}$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - "endpointName": _SERIALIZER.url( - "endpoint_name", endpoint_name, "str", max_length=64, min_length=1, pattern=r"^[A-Za-z0-9-._]{1,64}$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_03_01_preview.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_digital_twins_operations.py deleted file mode 100644 index 4ca69fe011d2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1276 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", max_length=64, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=3), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_03_01_preview.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_03_01_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_operations.py deleted file mode 100644 index 2d081064683d..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/operations/_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DigitalTwins/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_03_01_preview.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-03-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_03_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_azure_digital_twins_management_client.py deleted file mode 100644 index e9f0e1eacbcf..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,100 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import DigitalTwinsEndpointOperations, DigitalTwinsOperations, Operations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2020_10_31.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_configuration.py deleted file mode 100644 index bb0cf50d4ac1..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", "2020-10-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_metadata.json deleted file mode 100644 index c123e457a11d..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2020-10-31", - "total_api_version_list": ["2020-10-31"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index 6f1622f54a9d..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,101 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import DigitalTwinsEndpointOperations, DigitalTwinsOperations, Operations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2020_10_31.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2020_10_31.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2020_10_31.aio.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_configuration.py deleted file mode 100644 index 0e464db5ca0c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", "2020-10-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/__init__.py deleted file mode 100644 index a2f402ab0c76..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index 84c8cbaafacf..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_endpoint_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_10_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_operations.py deleted file mode 100644 index 8490f838da9f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_10_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/__init__.py deleted file mode 100644 index d28ef89e96d3..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# 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 CheckNameRequest -from ._models_py3 import CheckNameResult -from ._models_py3 import DigitalTwinsDescription -from ._models_py3 import DigitalTwinsDescriptionListResult -from ._models_py3 import DigitalTwinsEndpointResource -from ._models_py3 import DigitalTwinsEndpointResourceListResult -from ._models_py3 import DigitalTwinsEndpointResourceProperties -from ._models_py3 import DigitalTwinsPatchDescription -from ._models_py3 import DigitalTwinsResource -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorResponse -from ._models_py3 import EventGrid -from ._models_py3 import EventHub -from ._models_py3 import ExternalResource -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import ServiceBus - -from ._azure_digital_twins_management_client_enums import EndpointProvisioningState -from ._azure_digital_twins_management_client_enums import EndpointType -from ._azure_digital_twins_management_client_enums import ProvisioningState -from ._azure_digital_twins_management_client_enums import Reason -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CheckNameRequest", - "CheckNameResult", - "DigitalTwinsDescription", - "DigitalTwinsDescriptionListResult", - "DigitalTwinsEndpointResource", - "DigitalTwinsEndpointResourceListResult", - "DigitalTwinsEndpointResourceProperties", - "DigitalTwinsPatchDescription", - "DigitalTwinsResource", - "ErrorDefinition", - "ErrorResponse", - "EventGrid", - "EventHub", - "ExternalResource", - "Operation", - "OperationDisplay", - "OperationListResult", - "ServiceBus", - "EndpointProvisioningState", - "EndpointType", - "ProvisioningState", - "Reason", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_azure_digital_twins_management_client_enums.py deleted file mode 100644 index 8bbd0c120fe4..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_azure_digital_twins_management_client_enums.py +++ /dev/null @@ -1,56 +0,0 @@ -# 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 azure.core import CaseInsensitiveEnumMeta - - -class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" - - -class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Digital Twins endpoint.""" - - EVENT_HUB = "EventHub" - EVENT_GRID = "EventGrid" - SERVICE_BUS = "ServiceBus" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - - -class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Message providing the reason why the given name is invalid.""" - - INVALID = "Invalid" - ALREADY_EXISTS = "AlreadyExists" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_models_py3.py deleted file mode 100644 index 65f45b8b7fb8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_models_py3.py +++ /dev/null @@ -1,789 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CheckNameRequest(_serialization.Model): - """The result returned from a database check name availability request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. Required. - :vartype name: str - :ivar type: The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. - Required. Default value is "Microsoft.DigitalTwins/digitalTwinsInstances". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.DigitalTwins/digitalTwinsInstances" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Resource name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameResult(_serialization.Model): - """The result returned from a check name availability request. - - :ivar name_available: Specifies a Boolean value that indicates if the name is available. - :vartype name_available: bool - :ivar message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2020_10_31.models.Reason - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - message: Optional[str] = None, - reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Specifies a Boolean value that indicates if the name is available. - :paramtype name_available: bool - :keyword message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2020_10_31.models.Reason - """ - super().__init__(**kwargs) - self.name_available = name_available - self.message = message - self.reason = reason - - -class DigitalTwinsResource(_serialization.Model): - """The common properties of a DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class DigitalTwinsDescription(DigitalTwinsResource): - """The description of the DigitalTwins service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar created_time: Time when DigitalTwinsInstance was created. - :vartype created_time: ~datetime.datetime - :ivar last_updated_time: Time when DigitalTwinsInstance was updated. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", and - "Moving". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_10_31.models.ProvisioningState - :ivar host_name: Api endpoint to work with DigitalTwinsInstance. - :vartype host_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.created_time = None - self.last_updated_time = None - self.provisioning_state = None - self.host_name = None - - -class DigitalTwinsDescriptionListResult(_serialization.Model): - """A list of DigitalTwins description objects with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins description objects. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsDescription]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsDescription"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - :keyword value: A list of DigitalTwins description objects. - :paramtype value: list[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsDescription] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class ExternalResource(_serialization.Model): - """Definition of a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DigitalTwinsEndpointResource(ExternalResource): - """DigitalTwinsInstance endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: DigitalTwinsInstance endpoint resource properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "DigitalTwinsEndpointResourceProperties"}, - } - - def __init__(self, *, properties: "_models.DigitalTwinsEndpointResourceProperties", **kwargs: Any) -> None: - """ - :keyword properties: DigitalTwinsInstance endpoint resource properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class DigitalTwinsEndpointResourceListResult(_serialization.Model): - """A list of DigitalTwinsInstance Endpoints with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :vartype next_link: str - :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsEndpointResource]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsEndpointResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :paramtype next_link: str - :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class DigitalTwinsEndpointResourceProperties(_serialization.Model): - """Properties related to Digital Twins Endpoint. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventGrid, EventHub, ServiceBus - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :vartype dead_letter_secret: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - } - - _subtype_map = {"endpoint_type": {"EventGrid": "EventGrid", "EventHub": "EventHub", "ServiceBus": "ServiceBus"}} - - def __init__(self, *, dead_letter_secret: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :paramtype dead_letter_secret: str - """ - super().__init__(**kwargs) - self.endpoint_type: Optional[str] = None - self.provisioning_state = None - self.created_time = None - self.dead_letter_secret = dead_letter_secret - - -class DigitalTwinsPatchDescription(_serialization.Model): - """The description of the DigitalTwins service. - - :ivar tags: Instance tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Instance tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2020_10_31.models.ErrorDefinition] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2020_10_31.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2020_10_31.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class EventGrid(DigitalTwinsEndpointResourceProperties): - """Properties related to EventGrid. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :vartype dead_letter_secret: str - :ivar topic_endpoint: EventGrid Topic Endpoint. Required. - :vartype topic_endpoint: str - :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key1: str - :ivar access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :vartype access_key2: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "topic_endpoint": {"required": True}, - "access_key1": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "topic_endpoint": {"key": "TopicEndpoint", "type": "str"}, - "access_key1": {"key": "accessKey1", "type": "str"}, - "access_key2": {"key": "accessKey2", "type": "str"}, - } - - def __init__( - self, - *, - topic_endpoint: str, - access_key1: str, - dead_letter_secret: Optional[str] = None, - access_key2: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :paramtype dead_letter_secret: str - :keyword topic_endpoint: EventGrid Topic Endpoint. Required. - :paramtype topic_endpoint: str - :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key1: str - :keyword access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :paramtype access_key2: str - """ - super().__init__(dead_letter_secret=dead_letter_secret, **kwargs) - self.endpoint_type: str = "EventGrid" - self.topic_endpoint = topic_endpoint - self.access_key1 = access_key1 - self.access_key2 = access_key2 - - -class EventHub(DigitalTwinsEndpointResourceProperties): - """Properties related to EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :vartype dead_letter_secret: str - :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :vartype connection_string_primary_key: str - :ivar connection_string_secondary_key: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. - :vartype connection_string_secondary_key: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "connection_string_primary_key": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "connection_string_primary_key": {"key": "connectionStringPrimaryKey", "type": "str"}, - "connection_string_secondary_key": {"key": "connectionStringSecondaryKey", "type": "str"}, - } - - def __init__( - self, - *, - connection_string_primary_key: str, - dead_letter_secret: Optional[str] = None, - connection_string_secondary_key: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :paramtype dead_letter_secret: str - :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint. Will be - obfuscated during read. Required. - :paramtype connection_string_primary_key: str - :keyword connection_string_secondary_key: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. - :paramtype connection_string_secondary_key: str - """ - super().__init__(dead_letter_secret=dead_letter_secret, **kwargs) - self.endpoint_type: str = "EventHub" - self.connection_string_primary_key = connection_string_primary_key - self.connection_string_secondary_key = connection_string_secondary_key - - -class Operation(_serialization.Model): - """DigitalTwins service REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. - :vartype name: str - :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2020_10_31.models.OperationDisplay - :ivar origin: The intended executor of the operation. - :vartype origin: str - :ivar is_data_action: If the operation is a data action (for data plane rbac). - :vartype is_data_action: bool - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - "is_data_action": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2020_10_31.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.display = display - self.origin = None - self.is_data_action = None - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft DigitalTwins. - :vartype provider: str - :ivar resource: Resource Type: DigitalTwinsInstances. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Friendly description for the operation,. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of DigitalTwins 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 next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource - provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_10_31.models.Operation] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = None - - -class ServiceBus(DigitalTwinsEndpointResourceProperties): - """Properties related to ServiceBus. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :vartype dead_letter_secret: str - :ivar primary_connection_string: PrimaryConnectionString of the endpoint. Will be obfuscated - during read. Required. - :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. - :vartype secondary_connection_string: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "primary_connection_string": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - } - - def __init__( - self, - *, - primary_connection_string: str, - dead_letter_secret: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword dead_letter_secret: Dead letter storage secret. Will be obfuscated during read. - :paramtype dead_letter_secret: str - :keyword primary_connection_string: PrimaryConnectionString of the endpoint. Will be obfuscated - during read. Required. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the endpoint. Will be - obfuscated during read. - :paramtype secondary_connection_string: str - """ - super().__init__(dead_letter_secret=dead_letter_secret, **kwargs) - self.endpoint_type: str = "ServiceBus" - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/__init__.py deleted file mode 100644 index a2f402ab0c76..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index 34bfb0822f41..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,784 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=64, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_10_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_operations.py deleted file mode 100644 index c641c539e986..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DigitalTwins/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_10_31.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_10_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_10_31/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_azure_digital_twins_management_client.py deleted file mode 100644 index 5f9c9b215f69..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,118 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: azure.mgmt.digitaltwins.v2020_12_01.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2020_12_01.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2020_12_01.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2020_12_01.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2020_12_01.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_configuration.py deleted file mode 100644 index ddd3c75aad42..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", "2020-12-01") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_metadata.json deleted file mode 100644 index 6010d3c25e68..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2020-12-01", - "total_api_version_list": ["2020-12-01"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index ce15018f6ec3..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,119 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2020_12_01.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2020_12_01.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2020_12_01.aio.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2020_12_01.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2020_12_01.aio.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - 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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_configuration.py deleted file mode 100644 index 0c1ea0f0a30f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", "2020-12-01") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/__init__.py deleted file mode 100644 index 9382705d7dcf..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index b1a6763be1fe..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_endpoint_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_digital_twins_operations.py deleted file mode 100644 index 92016863f703..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1029 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_operations import ( - build_check_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, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index fafff8cd72e4..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,555 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 4b6fe072d8e1..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,187 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_resources_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/__init__.py deleted file mode 100644 index b4f552a0f1cc..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/__init__.py +++ /dev/null @@ -1,99 +0,0 @@ -# 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 CheckNameRequest -from ._models_py3 import CheckNameResult -from ._models_py3 import ConnectionProperties -from ._models_py3 import ConnectionPropertiesPrivateEndpoint -from ._models_py3 import ConnectionPropertiesPrivateLinkServiceConnectionState -from ._models_py3 import ConnectionState -from ._models_py3 import DigitalTwinsDescription -from ._models_py3 import DigitalTwinsDescriptionListResult -from ._models_py3 import DigitalTwinsEndpointResource -from ._models_py3 import DigitalTwinsEndpointResourceListResult -from ._models_py3 import DigitalTwinsEndpointResourceProperties -from ._models_py3 import DigitalTwinsIdentity -from ._models_py3 import DigitalTwinsPatchDescription -from ._models_py3 import DigitalTwinsPatchProperties -from ._models_py3 import DigitalTwinsResource -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorResponse -from ._models_py3 import EventGrid -from ._models_py3 import EventHub -from ._models_py3 import ExternalResource -from ._models_py3 import GroupIdInformation -from ._models_py3 import GroupIdInformationProperties -from ._models_py3 import GroupIdInformationPropertiesAutoGenerated -from ._models_py3 import GroupIdInformationResponse -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionProperties -from ._models_py3 import PrivateEndpointConnectionsResponse -from ._models_py3 import ServiceBus - -from ._azure_digital_twins_management_client_enums import AuthenticationType -from ._azure_digital_twins_management_client_enums import ConnectionPropertiesProvisioningState -from ._azure_digital_twins_management_client_enums import DigitalTwinsIdentityType -from ._azure_digital_twins_management_client_enums import EndpointProvisioningState -from ._azure_digital_twins_management_client_enums import EndpointType -from ._azure_digital_twins_management_client_enums import PrivateLinkServiceConnectionStatus -from ._azure_digital_twins_management_client_enums import ProvisioningState -from ._azure_digital_twins_management_client_enums import PublicNetworkAccess -from ._azure_digital_twins_management_client_enums import Reason -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CheckNameRequest", - "CheckNameResult", - "ConnectionProperties", - "ConnectionPropertiesPrivateEndpoint", - "ConnectionPropertiesPrivateLinkServiceConnectionState", - "ConnectionState", - "DigitalTwinsDescription", - "DigitalTwinsDescriptionListResult", - "DigitalTwinsEndpointResource", - "DigitalTwinsEndpointResourceListResult", - "DigitalTwinsEndpointResourceProperties", - "DigitalTwinsIdentity", - "DigitalTwinsPatchDescription", - "DigitalTwinsPatchProperties", - "DigitalTwinsResource", - "ErrorDefinition", - "ErrorResponse", - "EventGrid", - "EventHub", - "ExternalResource", - "GroupIdInformation", - "GroupIdInformationProperties", - "GroupIdInformationPropertiesAutoGenerated", - "GroupIdInformationResponse", - "Operation", - "OperationDisplay", - "OperationListResult", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionProperties", - "PrivateEndpointConnectionsResponse", - "ServiceBus", - "AuthenticationType", - "ConnectionPropertiesProvisioningState", - "DigitalTwinsIdentityType", - "EndpointProvisioningState", - "EndpointType", - "PrivateLinkServiceConnectionStatus", - "ProvisioningState", - "PublicNetworkAccess", - "Reason", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_azure_digital_twins_management_client_enums.py deleted file mode 100644 index a73b22f85136..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_azure_digital_twins_management_client_enums.py +++ /dev/null @@ -1,98 +0,0 @@ -# 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 azure.core import CaseInsensitiveEnumMeta - - -class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the authentication type being used for connecting to the endpoint.""" - - KEY_BASED = "KeyBased" - IDENTITY_BASED = "IdentityBased" - - -class ConnectionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class DigitalTwinsIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is - supported. - """ - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - - -class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" - - -class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Digital Twins endpoint.""" - - EVENT_HUB = "EventHub" - EVENT_GRID = "EventGrid" - SERVICE_BUS = "ServiceBus" - - -class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of a private endpoint connection.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Public network access for the DigitalTwinsInstance.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Message providing the reason why the given name is invalid.""" - - INVALID = "Invalid" - ALREADY_EXISTS = "AlreadyExists" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_models_py3.py deleted file mode 100644 index 7664adc7ef66..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_models_py3.py +++ /dev/null @@ -1,1528 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CheckNameRequest(_serialization.Model): - """The result returned from a database check name availability request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. Required. - :vartype name: str - :ivar type: The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. - Required. Default value is "Microsoft.DigitalTwins/digitalTwinsInstances". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.DigitalTwins/digitalTwinsInstances" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Resource name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameResult(_serialization.Model): - """The result returned from a check name availability request. - - :ivar name_available: Specifies a Boolean value that indicates if the name is available. - :vartype name_available: bool - :ivar message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.Reason - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - message: Optional[str] = None, - reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Specifies a Boolean value that indicates if the name is available. - :paramtype name_available: bool - :keyword message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.Reason - """ - super().__init__(**kwargs) - self.name_available = name_available - self.message = message - self.reason = reason - - -class ConnectionProperties(_serialization.Model): - """The properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state. Known values are: "Pending", "Approved", - "Rejected", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesProvisioningState - :ivar private_endpoint: - :vartype private_endpoint: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateEndpoint - :ivar group_ids: The list of group ids for the private endpoint connection. - :vartype group_ids: list[str] - :ivar private_link_service_connection_state: - :vartype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint": {"key": "privateEndpoint", "type": "ConnectionPropertiesPrivateEndpoint"}, - "group_ids": {"key": "groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "ConnectionPropertiesPrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.ConnectionPropertiesPrivateEndpoint"] = None, - group_ids: Optional[List[str]] = None, - private_link_service_connection_state: Optional[ - "_models.ConnectionPropertiesPrivateLinkServiceConnectionState" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: - :paramtype private_endpoint: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateEndpoint - :keyword group_ids: The list of group ids for the private endpoint connection. - :paramtype group_ids: list[str] - :keyword private_link_service_connection_state: - :paramtype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint = private_endpoint - self.group_ids = group_ids - self.private_link_service_connection_state = private_link_service_connection_state - - -class PrivateEndpoint(_serialization.Model): - """The private endpoint property of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class ConnectionPropertiesPrivateEndpoint(PrivateEndpoint): - """ConnectionPropertiesPrivateEndpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class ConnectionState(_serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): - """ConnectionPropertiesPrivateLinkServiceConnectionState. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(status=status, description=description, actions_required=actions_required, **kwargs) - - -class DigitalTwinsResource(_serialization.Model): - """The common properties of a DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentity - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentity - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.identity = identity - - -class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many-instance-attributes - """The description of the DigitalTwins service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentity - :ivar created_time: Time when DigitalTwinsInstance was created. - :vartype created_time: ~datetime.datetime - :ivar last_updated_time: Time when DigitalTwinsInstance was updated. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - and "Moving". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.ProvisioningState - :ivar host_name: Api endpoint to work with DigitalTwinsInstance. - :vartype host_name: str - :ivar private_endpoint_connections: - :vartype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PublicNetworkAccess - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentity - :keyword private_endpoint_connections: - :paramtype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PublicNetworkAccess - """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) - self.created_time = None - self.last_updated_time = None - self.provisioning_state = None - self.host_name = None - self.private_endpoint_connections = private_endpoint_connections - self.public_network_access = public_network_access - - -class DigitalTwinsDescriptionListResult(_serialization.Model): - """A list of DigitalTwins description objects with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins description objects. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsDescription]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsDescription"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - :keyword value: A list of DigitalTwins description objects. - :paramtype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class ExternalResource(_serialization.Model): - """Definition of a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DigitalTwinsEndpointResource(ExternalResource): - """DigitalTwinsInstance endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: DigitalTwinsInstance endpoint resource properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "DigitalTwinsEndpointResourceProperties"}, - } - - def __init__(self, *, properties: "_models.DigitalTwinsEndpointResourceProperties", **kwargs: Any) -> None: - """ - :keyword properties: DigitalTwinsInstance endpoint resource properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class DigitalTwinsEndpointResourceListResult(_serialization.Model): - """A list of DigitalTwinsInstance Endpoints with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :vartype next_link: str - :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsEndpointResource]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsEndpointResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :paramtype next_link: str - :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class DigitalTwinsEndpointResourceProperties(_serialization.Model): - """Properties related to Digital Twins Endpoint. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventGrid, EventHub, ServiceBus - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - } - - _subtype_map = {"endpoint_type": {"EventGrid": "EventGrid", "EventHub": "EventHub", "ServiceBus": "ServiceBus"}} - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - """ - super().__init__(**kwargs) - self.endpoint_type: Optional[str] = None - self.provisioning_state = None - self.created_time = None - self.authentication_type = authentication_type - self.dead_letter_secret = dead_letter_secret - self.dead_letter_uri = dead_letter_uri - - -class DigitalTwinsIdentity(_serialization.Model): - """The managed identity for the DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned - is supported. Known values are: "None" and "SystemAssigned". - :vartype type: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.DigitalTwinsIdentityType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of Managed Identity used by the DigitalTwinsInstance. Only - SystemAssigned is supported. Known values are: "None" and "SystemAssigned". - :paramtype type: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentityType - """ - super().__init__(**kwargs) - self.type = type - self.principal_id = None - self.tenant_id = None - - -class DigitalTwinsPatchDescription(_serialization.Model): - """The description of the DigitalTwins service. - - :ivar tags: Instance patch properties. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentity - :ivar properties: Properties for the DigitalTwinsInstance. - :vartype properties: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsPatchProperties - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "DigitalTwinsIdentity"}, - "properties": {"key": "properties", "type": "DigitalTwinsPatchProperties"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.DigitalTwinsIdentity"] = None, - properties: Optional["_models.DigitalTwinsPatchProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Instance patch properties. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsIdentity - :keyword properties: Properties for the DigitalTwinsInstance. - :paramtype properties: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsPatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.properties = properties - - -class DigitalTwinsPatchProperties(_serialization.Model): - """The properties of a DigitalTwinsInstance. - - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PublicNetworkAccess - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, *, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.PublicNetworkAccess - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2020_12_01.models.ErrorDefinition] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2020_12_01.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2020_12_01.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class EventGrid(DigitalTwinsEndpointResourceProperties): - """Properties related to EventGrid. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar topic_endpoint: EventGrid Topic Endpoint. Required. - :vartype topic_endpoint: str - :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key1: str - :ivar access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :vartype access_key2: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "topic_endpoint": {"required": True}, - "access_key1": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "topic_endpoint": {"key": "TopicEndpoint", "type": "str"}, - "access_key1": {"key": "accessKey1", "type": "str"}, - "access_key2": {"key": "accessKey2", "type": "str"}, - } - - def __init__( - self, - *, - topic_endpoint: str, - access_key1: str, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - access_key2: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword topic_endpoint: EventGrid Topic Endpoint. Required. - :paramtype topic_endpoint: str - :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key1: str - :keyword access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :paramtype access_key2: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "EventGrid" - self.topic_endpoint = topic_endpoint - self.access_key1 = access_key1 - self.access_key2 = access_key2 - - -class EventHub(DigitalTwinsEndpointResourceProperties): - """Properties related to EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_primary_key: str - :ivar connection_string_secondary_key: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_secondary_key: str - :ivar endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol sb://. - :vartype endpoint_uri: str - :ivar entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "connection_string_primary_key": {"key": "connectionStringPrimaryKey", "type": "str"}, - "connection_string_secondary_key": {"key": "connectionStringSecondaryKey", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - connection_string_primary_key: Optional[str] = None, - connection_string_secondary_key: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype connection_string_primary_key: str - :keyword connection_string_secondary_key: SecondaryConnectionString of the endpoint for - key-based authentication. Will be obfuscated during read. - :paramtype connection_string_secondary_key: str - :keyword endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol sb://. - :paramtype endpoint_uri: str - :keyword entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "EventHub" - self.connection_string_primary_key = connection_string_primary_key - self.connection_string_secondary_key = connection_string_secondary_key - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class GroupIdInformation(_serialization.Model): - """The group information for creating a private endpoint on Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar properties: Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformationProperties - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "properties": {"required": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - properties: "_models.GroupIdInformationProperties", - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword properties: Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformationProperties - :keyword id: The resource identifier. - :paramtype id: str - """ - super().__init__(**kwargs) - self.properties = properties - self.id = id - self.name = None - self.type = None - - -class GroupIdInformationPropertiesAutoGenerated(_serialization.Model): - """The properties for a group information object. - - :ivar group_id: The group id. - :vartype group_id: str - :ivar required_members: The required members for a specific group id. - :vartype required_members: list[str] - :ivar required_zone_names: The required DNS zones for a specific group id. - :vartype required_zone_names: list[str] - """ - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - required_members: Optional[List[str]] = None, - required_zone_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The group id. - :paramtype group_id: str - :keyword required_members: The required members for a specific group id. - :paramtype required_members: list[str] - :keyword required_zone_names: The required DNS zones for a specific group id. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = group_id - self.required_members = required_members - self.required_zone_names = required_zone_names - - -class GroupIdInformationProperties(GroupIdInformationPropertiesAutoGenerated): - """GroupIdInformationProperties. - - :ivar group_id: The group id. - :vartype group_id: str - :ivar required_members: The required members for a specific group id. - :vartype required_members: list[str] - :ivar required_zone_names: The required DNS zones for a specific group id. - :vartype required_zone_names: list[str] - """ - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - required_members: Optional[List[str]] = None, - required_zone_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The group id. - :paramtype group_id: str - :keyword required_members: The required members for a specific group id. - :paramtype required_members: list[str] - :keyword required_zone_names: The required DNS zones for a specific group id. - :paramtype required_zone_names: list[str] - """ - super().__init__( - group_id=group_id, required_members=required_members, required_zone_names=required_zone_names, **kwargs - ) - - -class GroupIdInformationResponse(_serialization.Model): - """The available private link resources for a Digital Twin. - - :ivar value: The list of available private link resources for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformation] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GroupIdInformation]"}, - } - - def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link resources for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformation] - """ - super().__init__(**kwargs) - self.value = value - - -class Operation(_serialization.Model): - """DigitalTwins service REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. - :vartype name: str - :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2020_12_01.models.OperationDisplay - :ivar origin: The intended executor of the operation. - :vartype origin: str - :ivar is_data_action: If the operation is a data action (for data plane rbac). - :vartype is_data_action: bool - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - "is_data_action": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2020_12_01.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.display = display - self.origin = None - self.is_data_action = None - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft DigitalTwins. - :vartype provider: str - :ivar resource: Resource Type: DigitalTwinsInstances. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Friendly description for the operation,. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of DigitalTwins 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 next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource - provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.Operation] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = None - - -class PrivateEndpointConnection(_serialization.Model): - """The private endpoint connection of a Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, - } - - def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs: Any) -> None: - """ - :keyword properties: Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnectionProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties - - -class PrivateEndpointConnectionProperties(ConnectionProperties): - """PrivateEndpointConnectionProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state. Known values are: "Pending", "Approved", - "Rejected", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesProvisioningState - :ivar private_endpoint: - :vartype private_endpoint: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateEndpoint - :ivar group_ids: The list of group ids for the private endpoint connection. - :vartype group_ids: list[str] - :ivar private_link_service_connection_state: - :vartype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint": {"key": "privateEndpoint", "type": "ConnectionPropertiesPrivateEndpoint"}, - "group_ids": {"key": "groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "ConnectionPropertiesPrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.ConnectionPropertiesPrivateEndpoint"] = None, - group_ids: Optional[List[str]] = None, - private_link_service_connection_state: Optional[ - "_models.ConnectionPropertiesPrivateLinkServiceConnectionState" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: - :paramtype private_endpoint: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateEndpoint - :keyword group_ids: The list of group ids for the private endpoint connection. - :paramtype group_ids: list[str] - :keyword private_link_service_connection_state: - :paramtype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2020_12_01.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - super().__init__( - private_endpoint=private_endpoint, - group_ids=group_ids, - private_link_service_connection_state=private_link_service_connection_state, - **kwargs - ) - - -class PrivateEndpointConnectionsResponse(_serialization.Model): - """The available private link connections for a Digital Twin. - - :ivar value: The list of available private link connections for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link connections for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - - -class ServiceBus(DigitalTwinsEndpointResourceProperties): - """Properties related to ServiceBus. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Known values are: "KeyBased" and "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype secondary_connection_string: str - :ivar endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. It - must include the protocol sb://. - :vartype endpoint_uri: str - :ivar entity_path: The ServiceBus Topic name for identity-based authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - primary_connection_string: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Known values are: "KeyBased" and "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2020_12_01.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype secondary_connection_string: str - :keyword endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. - It must include the protocol sb://. - :paramtype endpoint_uri: str - :keyword entity_path: The ServiceBus Topic name for identity-based authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "ServiceBus" - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/__init__.py deleted file mode 100644 index 9382705d7dcf..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index 3606824e7816..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,784 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_digital_twins_operations.py deleted file mode 100644 index 4ba99d80d8da..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1274 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=3), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_operations.py deleted file mode 100644 index 8f5ef452c37b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DigitalTwins/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2020_12_01.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2020_12_01.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index ff9121366da9..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,737 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2020_12_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_private_link_resources_operations.py deleted file mode 100644 index a499c0939a6f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,269 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2020_12_01.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2020_12_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_azure_digital_twins_management_client.py deleted file mode 100644 index ac4425248d0b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2021_06_30_preview.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2021_06_30_preview.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2021_06_30_preview.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2021_06_30_preview.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2021_06_30_preview.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2021_06_30_preview.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-06-30-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_configuration.py deleted file mode 100644 index 81964d7b507f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-06-30-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-06-30-preview"] = kwargs.pop("api_version", "2021-06-30-preview") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_metadata.json deleted file mode 100644 index a8d40f3b5ac0..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2021-06-30-preview", - "total_api_version_list": ["2021-06-30-preview"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "time_series_database_connections": "TimeSeriesDatabaseConnectionsOperations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index 8c0df5fa7489..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2021_06_30_preview.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2021_06_30_preview.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2021_06_30_preview.aio.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2021_06_30_preview.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2021_06_30_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2021_06_30_preview.aio.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-06-30-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - 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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_configuration.py deleted file mode 100644 index 6da71dd9a29c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-06-30-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-06-30-preview"] = kwargs.pop("api_version", "2021-06-30-preview") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index b50e8d83414a..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,612 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_endpoint_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_digital_twins_operations.py deleted file mode 100644 index 63187d008b91..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1050 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_operations import ( - build_check_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, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_operations.py deleted file mode 100644 index e598b30b77db..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_operations.py +++ /dev/null @@ -1,140 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 982d14e360e7..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,567 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 812b942230f2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,191 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_resources_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_time_series_database_connections_operations.py deleted file mode 100644 index 876d85af593c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/aio/operations/_time_series_database_connections_operations.py +++ /dev/null @@ -1,612 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._time_series_database_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TimeSeriesDatabaseConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.aio.AzureDigitalTwinsManagementClient`'s - :attr:`time_series_database_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.TimeSeriesDatabaseConnection"]: - """Get all existing time series database connections for this DigitalTwins instance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("TimeSeriesDatabaseConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - """Get the description of an existing time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): - _content = time_series_database_connection_description - else: - _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: _models.TimeSeriesDatabaseConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - time_series_database_connection_description=time_series_database_connection_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Delete a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/__init__.py deleted file mode 100644 index 1816c624f2c4..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/__init__.py +++ /dev/null @@ -1,109 +0,0 @@ -# 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 AzureDataExplorerConnectionProperties -from ._models_py3 import CheckNameRequest -from ._models_py3 import CheckNameResult -from ._models_py3 import ConnectionProperties -from ._models_py3 import ConnectionPropertiesPrivateLinkServiceConnectionState -from ._models_py3 import ConnectionState -from ._models_py3 import DigitalTwinsDescription -from ._models_py3 import DigitalTwinsDescriptionListResult -from ._models_py3 import DigitalTwinsEndpointResource -from ._models_py3 import DigitalTwinsEndpointResourceListResult -from ._models_py3 import DigitalTwinsEndpointResourceProperties -from ._models_py3 import DigitalTwinsIdentity -from ._models_py3 import DigitalTwinsPatchDescription -from ._models_py3 import DigitalTwinsPatchProperties -from ._models_py3 import DigitalTwinsResource -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorResponse -from ._models_py3 import EventGrid -from ._models_py3 import EventHub -from ._models_py3 import ExternalResource -from ._models_py3 import GroupIdInformation -from ._models_py3 import GroupIdInformationProperties -from ._models_py3 import GroupIdInformationResponse -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionsResponse -from ._models_py3 import ServiceBus -from ._models_py3 import SystemData -from ._models_py3 import TimeSeriesDatabaseConnection -from ._models_py3 import TimeSeriesDatabaseConnectionListResult -from ._models_py3 import TimeSeriesDatabaseConnectionProperties - -from ._azure_digital_twins_management_client_enums import AuthenticationType -from ._azure_digital_twins_management_client_enums import ConnectionPropertiesProvisioningState -from ._azure_digital_twins_management_client_enums import ConnectionType -from ._azure_digital_twins_management_client_enums import CreatedByType -from ._azure_digital_twins_management_client_enums import DigitalTwinsIdentityType -from ._azure_digital_twins_management_client_enums import EndpointProvisioningState -from ._azure_digital_twins_management_client_enums import EndpointType -from ._azure_digital_twins_management_client_enums import PrivateLinkServiceConnectionStatus -from ._azure_digital_twins_management_client_enums import ProvisioningState -from ._azure_digital_twins_management_client_enums import PublicNetworkAccess -from ._azure_digital_twins_management_client_enums import Reason -from ._azure_digital_twins_management_client_enums import TimeSeriesDatabaseConnectionState -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDataExplorerConnectionProperties", - "CheckNameRequest", - "CheckNameResult", - "ConnectionProperties", - "ConnectionPropertiesPrivateLinkServiceConnectionState", - "ConnectionState", - "DigitalTwinsDescription", - "DigitalTwinsDescriptionListResult", - "DigitalTwinsEndpointResource", - "DigitalTwinsEndpointResourceListResult", - "DigitalTwinsEndpointResourceProperties", - "DigitalTwinsIdentity", - "DigitalTwinsPatchDescription", - "DigitalTwinsPatchProperties", - "DigitalTwinsResource", - "ErrorDefinition", - "ErrorResponse", - "EventGrid", - "EventHub", - "ExternalResource", - "GroupIdInformation", - "GroupIdInformationProperties", - "GroupIdInformationResponse", - "Operation", - "OperationDisplay", - "OperationListResult", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionsResponse", - "ServiceBus", - "SystemData", - "TimeSeriesDatabaseConnection", - "TimeSeriesDatabaseConnectionListResult", - "TimeSeriesDatabaseConnectionProperties", - "AuthenticationType", - "ConnectionPropertiesProvisioningState", - "ConnectionType", - "CreatedByType", - "DigitalTwinsIdentityType", - "EndpointProvisioningState", - "EndpointType", - "PrivateLinkServiceConnectionStatus", - "ProvisioningState", - "PublicNetworkAccess", - "Reason", - "TimeSeriesDatabaseConnectionState", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_azure_digital_twins_management_client_enums.py deleted file mode 100644 index 0bf112301ae1..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_azure_digital_twins_management_client_enums.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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 azure.core import CaseInsensitiveEnumMeta - - -class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the authentication type being used for connecting to the endpoint. Defaults to - 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the - primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath - properties must be specified. - """ - - KEY_BASED = "KeyBased" - IDENTITY_BASED = "IdentityBased" - - -class ConnectionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of time series connection resource.""" - - AZURE_DATA_EXPLORER = "AzureDataExplorer" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DigitalTwinsIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is - supported. - """ - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - - -class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" - - -class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Digital Twins endpoint.""" - - EVENT_HUB = "EventHub" - EVENT_GRID = "EventGrid" - SERVICE_BUS = "ServiceBus" - - -class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of a private endpoint connection.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Public network access for the DigitalTwinsInstance.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Message providing the reason why the given name is invalid.""" - - INVALID = "Invalid" - ALREADY_EXISTS = "AlreadyExists" - - -class TimeSeriesDatabaseConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_models_py3.py deleted file mode 100644 index 9b22773fcfe7..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_models_py3.py +++ /dev/null @@ -1,1767 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class TimeSeriesDatabaseConnectionProperties(_serialization.Model): - """Properties of a time series database connection resource. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureDataExplorerConnectionProperties - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar connection_type: The type of time series connection resource. Required. - "AzureDataExplorer" - :vartype connection_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnectionState - """ - - _validation = { - "connection_type": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "connection_type": {"key": "connectionType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - _subtype_map = {"connection_type": {"AzureDataExplorer": "AzureDataExplorerConnectionProperties"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.connection_type: Optional[str] = None - self.provisioning_state = None - - -class AzureDataExplorerConnectionProperties(TimeSeriesDatabaseConnectionProperties): - """Properties of a time series database connection to Azure Data Explorer with data being sent via - an EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar connection_type: The type of time series connection resource. Required. - "AzureDataExplorer" - :vartype connection_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnectionState - :ivar adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. - :vartype adx_resource_id: str - :ivar adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. - :vartype adx_endpoint_uri: str - :ivar adx_database_name: The name of the Azure Data Explorer database. Required. - :vartype adx_database_name: str - :ivar adx_table_name: The name of the Azure Data Explorer table. Defaults to AdtPropertyEvents. - :vartype adx_table_name: str - :ivar event_hub_endpoint_uri: The URL of the EventHub namespace for identity-based - authentication. It must include the protocol sb://. Required. - :vartype event_hub_endpoint_uri: str - :ivar event_hub_entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. Required. - :vartype event_hub_entity_path: str - :ivar event_hub_namespace_resource_id: The resource ID of the EventHub namespace. Required. - :vartype event_hub_namespace_resource_id: str - :ivar event_hub_consumer_group: The EventHub consumer group to use when ADX reads from - EventHub. Defaults to $Default. - :vartype event_hub_consumer_group: str - """ - - _validation = { - "connection_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "adx_resource_id": {"required": True}, - "adx_endpoint_uri": {"required": True}, - "adx_database_name": {"required": True}, - "event_hub_endpoint_uri": {"required": True}, - "event_hub_entity_path": {"required": True}, - "event_hub_namespace_resource_id": {"required": True}, - } - - _attribute_map = { - "connection_type": {"key": "connectionType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "adx_resource_id": {"key": "adxResourceId", "type": "str"}, - "adx_endpoint_uri": {"key": "adxEndpointUri", "type": "str"}, - "adx_database_name": {"key": "adxDatabaseName", "type": "str"}, - "adx_table_name": {"key": "adxTableName", "type": "str"}, - "event_hub_endpoint_uri": {"key": "eventHubEndpointUri", "type": "str"}, - "event_hub_entity_path": {"key": "eventHubEntityPath", "type": "str"}, - "event_hub_namespace_resource_id": {"key": "eventHubNamespaceResourceId", "type": "str"}, - "event_hub_consumer_group": {"key": "eventHubConsumerGroup", "type": "str"}, - } - - def __init__( - self, - *, - adx_resource_id: str, - adx_endpoint_uri: str, - adx_database_name: str, - event_hub_endpoint_uri: str, - event_hub_entity_path: str, - event_hub_namespace_resource_id: str, - adx_table_name: str = "AdtPropertyEvents", - event_hub_consumer_group: str = "$Default", - **kwargs: Any - ) -> None: - """ - :keyword adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. - :paramtype adx_resource_id: str - :keyword adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. - :paramtype adx_endpoint_uri: str - :keyword adx_database_name: The name of the Azure Data Explorer database. Required. - :paramtype adx_database_name: str - :keyword adx_table_name: The name of the Azure Data Explorer table. Defaults to - AdtPropertyEvents. - :paramtype adx_table_name: str - :keyword event_hub_endpoint_uri: The URL of the EventHub namespace for identity-based - authentication. It must include the protocol sb://. Required. - :paramtype event_hub_endpoint_uri: str - :keyword event_hub_entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. Required. - :paramtype event_hub_entity_path: str - :keyword event_hub_namespace_resource_id: The resource ID of the EventHub namespace. Required. - :paramtype event_hub_namespace_resource_id: str - :keyword event_hub_consumer_group: The EventHub consumer group to use when ADX reads from - EventHub. Defaults to $Default. - :paramtype event_hub_consumer_group: str - """ - super().__init__(**kwargs) - self.connection_type: str = "AzureDataExplorer" - self.adx_resource_id = adx_resource_id - self.adx_endpoint_uri = adx_endpoint_uri - self.adx_database_name = adx_database_name - self.adx_table_name = adx_table_name - self.event_hub_endpoint_uri = event_hub_endpoint_uri - self.event_hub_entity_path = event_hub_entity_path - self.event_hub_namespace_resource_id = event_hub_namespace_resource_id - self.event_hub_consumer_group = event_hub_consumer_group - - -class CheckNameRequest(_serialization.Model): - """The result returned from a database check name availability request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. Required. - :vartype name: str - :ivar type: The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. - Required. Default value is "Microsoft.DigitalTwins/digitalTwinsInstances". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.DigitalTwins/digitalTwinsInstances" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Resource name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameResult(_serialization.Model): - """The result returned from a check name availability request. - - :ivar name_available: Specifies a Boolean value that indicates if the name is available. - :vartype name_available: bool - :ivar message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.Reason - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - message: Optional[str] = None, - reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Specifies a Boolean value that indicates if the name is available. - :paramtype name_available: bool - :keyword message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.Reason - """ - super().__init__(**kwargs) - self.name_available = name_available - self.message = message - self.reason = reason - - -class ConnectionProperties(_serialization.Model): - """The properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state. Known values are: "Pending", "Approved", - "Rejected", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionPropertiesProvisioningState - :ivar private_endpoint: The private endpoint. - :vartype private_endpoint: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpoint - :ivar group_ids: The list of group ids for the private endpoint connection. - :vartype group_ids: list[str] - :ivar private_link_service_connection_state: The connection state. - :vartype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, - "group_ids": {"key": "groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "ConnectionPropertiesPrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - group_ids: Optional[List[str]] = None, - private_link_service_connection_state: Optional[ - "_models.ConnectionPropertiesPrivateLinkServiceConnectionState" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The private endpoint. - :paramtype private_endpoint: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpoint - :keyword group_ids: The list of group ids for the private endpoint connection. - :paramtype group_ids: list[str] - :keyword private_link_service_connection_state: The connection state. - :paramtype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint = private_endpoint - self.group_ids = group_ids - self.private_link_service_connection_state = private_link_service_connection_state - - -class ConnectionState(_serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): - """The connection state. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(status=status, description=description, actions_required=actions_required, **kwargs) - - -class DigitalTwinsResource(_serialization.Model): - """The common properties of a DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the - DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentity - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.identity = identity - self.system_data = None - - -class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many-instance-attributes - """The description of the DigitalTwins service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the - DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.SystemData - :ivar created_time: Time when DigitalTwinsInstance was created. - :vartype created_time: ~datetime.datetime - :ivar last_updated_time: Time when DigitalTwinsInstance was updated. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - and "Moving". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ProvisioningState - :ivar host_name: Api endpoint to work with DigitalTwinsInstance. - :vartype host_name: str - :ivar private_endpoint_connections: The private endpoint connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PublicNetworkAccess - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentity - :keyword private_endpoint_connections: The private endpoint connections. - :paramtype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PublicNetworkAccess - """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) - self.created_time = None - self.last_updated_time = None - self.provisioning_state = None - self.host_name = None - self.private_endpoint_connections = private_endpoint_connections - self.public_network_access = public_network_access - - -class DigitalTwinsDescriptionListResult(_serialization.Model): - """A list of DigitalTwins description objects with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins description objects. - :vartype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsDescription]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsDescription"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - :keyword value: A list of DigitalTwins description objects. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class ExternalResource(_serialization.Model): - """Definition of a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class DigitalTwinsEndpointResource(ExternalResource): - """DigitalTwinsInstance endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.SystemData - :ivar properties: DigitalTwinsInstance endpoint resource properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "DigitalTwinsEndpointResourceProperties"}, - } - - def __init__(self, *, properties: "_models.DigitalTwinsEndpointResourceProperties", **kwargs: Any) -> None: - """ - :keyword properties: DigitalTwinsInstance endpoint resource properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class DigitalTwinsEndpointResourceListResult(_serialization.Model): - """A list of DigitalTwinsInstance Endpoints with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :vartype next_link: str - :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsEndpointResource]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsEndpointResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :paramtype next_link: str - :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class DigitalTwinsEndpointResourceProperties(_serialization.Model): - """Properties related to Digital Twins Endpoint. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventGrid, EventHub, ServiceBus - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - } - - _subtype_map = {"endpoint_type": {"EventGrid": "EventGrid", "EventHub": "EventHub", "ServiceBus": "ServiceBus"}} - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - """ - super().__init__(**kwargs) - self.endpoint_type: Optional[str] = None - self.provisioning_state = None - self.created_time = None - self.authentication_type = authentication_type - self.dead_letter_secret = dead_letter_secret - self.dead_letter_uri = dead_letter_uri - - -class DigitalTwinsIdentity(_serialization.Model): - """The managed identity for the DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned - is supported. Known values are: "None" and "SystemAssigned". - :vartype type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.DigitalTwinsIdentityType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of Managed Identity used by the DigitalTwinsInstance. Only - SystemAssigned is supported. Known values are: "None" and "SystemAssigned". - :paramtype type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentityType - """ - super().__init__(**kwargs) - self.type = type - self.principal_id = None - self.tenant_id = None - - -class DigitalTwinsPatchDescription(_serialization.Model): - """The description of the DigitalTwins service. - - :ivar tags: Instance patch properties. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentity - :ivar properties: Properties for the DigitalTwinsInstance. - :vartype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsPatchProperties - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "DigitalTwinsIdentity"}, - "properties": {"key": "properties", "type": "DigitalTwinsPatchProperties"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.DigitalTwinsIdentity"] = None, - properties: Optional["_models.DigitalTwinsPatchProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Instance patch properties. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsIdentity - :keyword properties: Properties for the DigitalTwinsInstance. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsPatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.properties = properties - - -class DigitalTwinsPatchProperties(_serialization.Model): - """The properties of a DigitalTwinsInstance. - - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PublicNetworkAccess - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, *, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PublicNetworkAccess - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ErrorDefinition] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class EventGrid(DigitalTwinsEndpointResourceProperties): - """Properties related to EventGrid. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar topic_endpoint: EventGrid Topic Endpoint. Required. - :vartype topic_endpoint: str - :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key1: str - :ivar access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :vartype access_key2: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "topic_endpoint": {"required": True}, - "access_key1": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "topic_endpoint": {"key": "TopicEndpoint", "type": "str"}, - "access_key1": {"key": "accessKey1", "type": "str"}, - "access_key2": {"key": "accessKey2", "type": "str"}, - } - - def __init__( - self, - *, - topic_endpoint: str, - access_key1: str, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - access_key2: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword topic_endpoint: EventGrid Topic Endpoint. Required. - :paramtype topic_endpoint: str - :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key1: str - :keyword access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :paramtype access_key2: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "EventGrid" - self.topic_endpoint = topic_endpoint - self.access_key1 = access_key1 - self.access_key2 = access_key2 - - -class EventHub(DigitalTwinsEndpointResourceProperties): - """Properties related to EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_primary_key: str - :ivar connection_string_secondary_key: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_secondary_key: str - :ivar endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol 'sb://'. - :vartype endpoint_uri: str - :ivar entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "connection_string_primary_key": {"key": "connectionStringPrimaryKey", "type": "str"}, - "connection_string_secondary_key": {"key": "connectionStringSecondaryKey", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - connection_string_primary_key: Optional[str] = None, - connection_string_secondary_key: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype connection_string_primary_key: str - :keyword connection_string_secondary_key: SecondaryConnectionString of the endpoint for - key-based authentication. Will be obfuscated during read. - :paramtype connection_string_secondary_key: str - :keyword endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol 'sb://'. - :paramtype endpoint_uri: str - :keyword entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "EventHub" - self.connection_string_primary_key = connection_string_primary_key - self.connection_string_secondary_key = connection_string_secondary_key - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class GroupIdInformation(_serialization.Model): - """The group information for creating a private endpoint on Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar properties: The group information properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformationProperties - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "properties": {"required": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - properties: "_models.GroupIdInformationProperties", - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword properties: The group information properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformationProperties - :keyword id: The resource identifier. - :paramtype id: str - """ - super().__init__(**kwargs) - self.properties = properties - self.id = id - self.name = None - self.type = None - - -class GroupIdInformationProperties(_serialization.Model): - """The properties for a group information object. - - :ivar group_id: The group id. - :vartype group_id: str - :ivar required_members: The required members for a specific group id. - :vartype required_members: list[str] - :ivar required_zone_names: The required DNS zones for a specific group id. - :vartype required_zone_names: list[str] - """ - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - required_members: Optional[List[str]] = None, - required_zone_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The group id. - :paramtype group_id: str - :keyword required_members: The required members for a specific group id. - :paramtype required_members: list[str] - :keyword required_zone_names: The required DNS zones for a specific group id. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = group_id - self.required_members = required_members - self.required_zone_names = required_zone_names - - -class GroupIdInformationResponse(_serialization.Model): - """The available private link resources for a Digital Twin. - - :ivar value: The list of available private link resources for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformation] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GroupIdInformation]"}, - } - - def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link resources for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformation] - """ - super().__init__(**kwargs) - self.value = value - - -class Operation(_serialization.Model): - """DigitalTwins service REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. - :vartype name: str - :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.OperationDisplay - :ivar origin: The intended executor of the operation. - :vartype origin: str - :ivar is_data_action: If the operation is a data action (for data plane rbac). - :vartype is_data_action: bool - :ivar properties: Operation properties. - :vartype properties: dict[str, JSON] - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - "is_data_action": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.display = display - self.origin = None - self.is_data_action = None - self.properties = None - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft DigitalTwins. - :vartype provider: str - :ivar resource: Resource Type: DigitalTwinsInstances. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Friendly description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of DigitalTwins 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 next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource - provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.Operation] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = None - - -class PrivateEndpoint(_serialization.Model): - """The private endpoint property of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(_serialization.Model): - """The private endpoint connection of a Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: The connection properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionProperties - :ivar system_data: Metadata pertaining to creation and last modification of the private - endpoint connection. - :vartype system_data: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "properties": {"required": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ConnectionProperties"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, properties: "_models.ConnectionProperties", **kwargs: Any) -> None: - """ - :keyword properties: The connection properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.ConnectionProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties - self.system_data = None - - -class PrivateEndpointConnectionsResponse(_serialization.Model): - """The available private link connections for a Digital Twin. - - :ivar value: The list of available private link connections for a Digital Twin. - :vartype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link connections for a Digital Twin. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - - -class ServiceBus(DigitalTwinsEndpointResourceProperties): - """Properties related to ServiceBus. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", "Moving", - and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype secondary_connection_string: str - :ivar endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. It - must include the protocol 'sb://'. - :vartype endpoint_uri: str - :ivar entity_path: The ServiceBus Topic name for identity-based authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - primary_connection_string: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype secondary_connection_string: str - :keyword endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. - It must include the protocol 'sb://'. - :paramtype endpoint_uri: str - :keyword entity_path: The ServiceBus Topic name for identity-based authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "ServiceBus" - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TimeSeriesDatabaseConnection(ExternalResource): - """Describes a time series database connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.SystemData - :ivar properties: Properties of a specific time series database connection. - :vartype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "TimeSeriesDatabaseConnectionProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.TimeSeriesDatabaseConnectionProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties of a specific time series database connection. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnectionProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class TimeSeriesDatabaseConnectionListResult(_serialization.Model): - """A pageable list of time series database connection resources. - - :ivar next_link: The link used to get the next page of results. - :vartype next_link: str - :ivar value: A list of time series database connection resources. - :vartype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[TimeSeriesDatabaseConnection]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.TimeSeriesDatabaseConnection"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of results. - :paramtype next_link: str - :keyword value: A list of time series database connection resources. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index f2127dddce88..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,804 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_digital_twins_operations.py deleted file mode 100644 index a593c737865a..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1309 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=3), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_operations.py deleted file mode 100644 index 96cb5afa967d..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DigitalTwins/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2021_06_30_preview.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index fe10eccb3174..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,757 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_private_link_resources_operations.py deleted file mode 100644 index eb7515db97e0..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,277 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_time_series_database_connections_operations.py deleted file mode 100644 index 57b482e72edf..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/operations/_time_series_database_connections_operations.py +++ /dev/null @@ -1,816 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.TimeSeriesDatabaseConnection"]: - """Get all existing time series database connections for this DigitalTwins instance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("TimeSeriesDatabaseConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - """Get the description of an existing time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): - _content = time_series_database_connection_description - else: - _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: _models.TimeSeriesDatabaseConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - time_series_database_connection_description=time_series_database_connection_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Delete a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2021_06_30_preview.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-30-preview") - ) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2021_06_30_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_azure_digital_twins_management_client.py deleted file mode 100644 index c5e3f3781e12..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,125 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: azure.mgmt.digitaltwins.v2022_05_31.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2022_05_31.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2022_05_31.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2022_05_31.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2022_05_31.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2022_05_31.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_configuration.py deleted file mode 100644 index 7f7b946d46a0..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", "2022-05-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_metadata.json deleted file mode 100644 index abaf36a9f38c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2022-05-31", - "total_api_version_list": ["2022-05-31"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "time_series_database_connections": "TimeSeriesDatabaseConnectionsOperations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index 00af944a28ff..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2022_05_31.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2022_05_31.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2022_05_31.aio.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2022_05_31.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2022_05_31.aio.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2022_05_31.aio.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - 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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_configuration.py deleted file mode 100644 index a6dabb7826fa..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", "2022-05-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/__init__.py deleted file mode 100644 index 791d2a1bb74f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._time_series_database_connections_operations import TimeSeriesDatabaseConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "TimeSeriesDatabaseConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index 52d828552dca..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_endpoint_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_digital_twins_operations.py deleted file mode 100644 index 92276af7f1d9..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1029 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_operations import ( - build_check_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, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_operations.py deleted file mode 100644 index b32f950ea425..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 600a423deecc..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,555 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 531de78e8238..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,187 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_resources_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_time_series_database_connections_operations.py deleted file mode 100644 index 39376c88a1dd..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/aio/operations/_time_series_database_connections_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._time_series_database_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TimeSeriesDatabaseConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`time_series_database_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.TimeSeriesDatabaseConnection"]: - """Get all existing time series database connections for this DigitalTwins instance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("TimeSeriesDatabaseConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - """Get the description of an existing time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): - _content = time_series_database_connection_description - else: - _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: _models.TimeSeriesDatabaseConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - time_series_database_connection_description=time_series_database_connection_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Delete a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/__init__.py deleted file mode 100644 index 1816c624f2c4..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/__init__.py +++ /dev/null @@ -1,109 +0,0 @@ -# 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 AzureDataExplorerConnectionProperties -from ._models_py3 import CheckNameRequest -from ._models_py3 import CheckNameResult -from ._models_py3 import ConnectionProperties -from ._models_py3 import ConnectionPropertiesPrivateLinkServiceConnectionState -from ._models_py3 import ConnectionState -from ._models_py3 import DigitalTwinsDescription -from ._models_py3 import DigitalTwinsDescriptionListResult -from ._models_py3 import DigitalTwinsEndpointResource -from ._models_py3 import DigitalTwinsEndpointResourceListResult -from ._models_py3 import DigitalTwinsEndpointResourceProperties -from ._models_py3 import DigitalTwinsIdentity -from ._models_py3 import DigitalTwinsPatchDescription -from ._models_py3 import DigitalTwinsPatchProperties -from ._models_py3 import DigitalTwinsResource -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorResponse -from ._models_py3 import EventGrid -from ._models_py3 import EventHub -from ._models_py3 import ExternalResource -from ._models_py3 import GroupIdInformation -from ._models_py3 import GroupIdInformationProperties -from ._models_py3 import GroupIdInformationResponse -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionsResponse -from ._models_py3 import ServiceBus -from ._models_py3 import SystemData -from ._models_py3 import TimeSeriesDatabaseConnection -from ._models_py3 import TimeSeriesDatabaseConnectionListResult -from ._models_py3 import TimeSeriesDatabaseConnectionProperties - -from ._azure_digital_twins_management_client_enums import AuthenticationType -from ._azure_digital_twins_management_client_enums import ConnectionPropertiesProvisioningState -from ._azure_digital_twins_management_client_enums import ConnectionType -from ._azure_digital_twins_management_client_enums import CreatedByType -from ._azure_digital_twins_management_client_enums import DigitalTwinsIdentityType -from ._azure_digital_twins_management_client_enums import EndpointProvisioningState -from ._azure_digital_twins_management_client_enums import EndpointType -from ._azure_digital_twins_management_client_enums import PrivateLinkServiceConnectionStatus -from ._azure_digital_twins_management_client_enums import ProvisioningState -from ._azure_digital_twins_management_client_enums import PublicNetworkAccess -from ._azure_digital_twins_management_client_enums import Reason -from ._azure_digital_twins_management_client_enums import TimeSeriesDatabaseConnectionState -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDataExplorerConnectionProperties", - "CheckNameRequest", - "CheckNameResult", - "ConnectionProperties", - "ConnectionPropertiesPrivateLinkServiceConnectionState", - "ConnectionState", - "DigitalTwinsDescription", - "DigitalTwinsDescriptionListResult", - "DigitalTwinsEndpointResource", - "DigitalTwinsEndpointResourceListResult", - "DigitalTwinsEndpointResourceProperties", - "DigitalTwinsIdentity", - "DigitalTwinsPatchDescription", - "DigitalTwinsPatchProperties", - "DigitalTwinsResource", - "ErrorDefinition", - "ErrorResponse", - "EventGrid", - "EventHub", - "ExternalResource", - "GroupIdInformation", - "GroupIdInformationProperties", - "GroupIdInformationResponse", - "Operation", - "OperationDisplay", - "OperationListResult", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionsResponse", - "ServiceBus", - "SystemData", - "TimeSeriesDatabaseConnection", - "TimeSeriesDatabaseConnectionListResult", - "TimeSeriesDatabaseConnectionProperties", - "AuthenticationType", - "ConnectionPropertiesProvisioningState", - "ConnectionType", - "CreatedByType", - "DigitalTwinsIdentityType", - "EndpointProvisioningState", - "EndpointType", - "PrivateLinkServiceConnectionStatus", - "ProvisioningState", - "PublicNetworkAccess", - "Reason", - "TimeSeriesDatabaseConnectionState", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_azure_digital_twins_management_client_enums.py deleted file mode 100644 index 696b5690cf62..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_azure_digital_twins_management_client_enums.py +++ /dev/null @@ -1,135 +0,0 @@ -# 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 azure.core import CaseInsensitiveEnumMeta - - -class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the authentication type being used for connecting to the endpoint. Defaults to - 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the - primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath - properties must be specified. - """ - - KEY_BASED = "KeyBased" - IDENTITY_BASED = "IdentityBased" - - -class ConnectionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of time series connection resource.""" - - AZURE_DATA_EXPLORER = "AzureDataExplorer" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DigitalTwinsIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is - supported. - """ - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - - -class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" - - -class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Digital Twins endpoint.""" - - EVENT_HUB = "EventHub" - EVENT_GRID = "EventGrid" - SERVICE_BUS = "ServiceBus" - - -class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of a private endpoint connection.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Public network access for the DigitalTwinsInstance.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Message providing the reason why the given name is invalid.""" - - INVALID = "Invalid" - ALREADY_EXISTS = "AlreadyExists" - - -class TimeSeriesDatabaseConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_models_py3.py deleted file mode 100644 index f93ada6c62ee..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_models_py3.py +++ /dev/null @@ -1,1750 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class TimeSeriesDatabaseConnectionProperties(_serialization.Model): - """Properties of a time series database connection resource. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureDataExplorerConnectionProperties - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar connection_type: The type of time series connection resource. Required. - "AzureDataExplorer" - :vartype connection_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnectionState - """ - - _validation = { - "connection_type": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "connection_type": {"key": "connectionType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - _subtype_map = {"connection_type": {"AzureDataExplorer": "AzureDataExplorerConnectionProperties"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.connection_type: Optional[str] = None - self.provisioning_state = None - - -class AzureDataExplorerConnectionProperties(TimeSeriesDatabaseConnectionProperties): - """Properties of a time series database connection to Azure Data Explorer with data being sent via - an EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar connection_type: The type of time series connection resource. Required. - "AzureDataExplorer" - :vartype connection_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnectionState - :ivar adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. - :vartype adx_resource_id: str - :ivar adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. - :vartype adx_endpoint_uri: str - :ivar adx_database_name: The name of the Azure Data Explorer database. Required. - :vartype adx_database_name: str - :ivar adx_table_name: The name of the Azure Data Explorer table. Defaults to AdtPropertyEvents. - :vartype adx_table_name: str - :ivar event_hub_endpoint_uri: The URL of the EventHub namespace for identity-based - authentication. It must include the protocol sb://. Required. - :vartype event_hub_endpoint_uri: str - :ivar event_hub_entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. Required. - :vartype event_hub_entity_path: str - :ivar event_hub_namespace_resource_id: The resource ID of the EventHub namespace. Required. - :vartype event_hub_namespace_resource_id: str - :ivar event_hub_consumer_group: The EventHub consumer group to use when ADX reads from - EventHub. Defaults to $Default. - :vartype event_hub_consumer_group: str - """ - - _validation = { - "connection_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "adx_resource_id": {"required": True}, - "adx_endpoint_uri": {"required": True}, - "adx_database_name": {"required": True}, - "event_hub_endpoint_uri": {"required": True}, - "event_hub_entity_path": {"required": True}, - "event_hub_namespace_resource_id": {"required": True}, - } - - _attribute_map = { - "connection_type": {"key": "connectionType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "adx_resource_id": {"key": "adxResourceId", "type": "str"}, - "adx_endpoint_uri": {"key": "adxEndpointUri", "type": "str"}, - "adx_database_name": {"key": "adxDatabaseName", "type": "str"}, - "adx_table_name": {"key": "adxTableName", "type": "str"}, - "event_hub_endpoint_uri": {"key": "eventHubEndpointUri", "type": "str"}, - "event_hub_entity_path": {"key": "eventHubEntityPath", "type": "str"}, - "event_hub_namespace_resource_id": {"key": "eventHubNamespaceResourceId", "type": "str"}, - "event_hub_consumer_group": {"key": "eventHubConsumerGroup", "type": "str"}, - } - - def __init__( - self, - *, - adx_resource_id: str, - adx_endpoint_uri: str, - adx_database_name: str, - event_hub_endpoint_uri: str, - event_hub_entity_path: str, - event_hub_namespace_resource_id: str, - adx_table_name: str = "AdtPropertyEvents", - event_hub_consumer_group: str = "$Default", - **kwargs: Any - ) -> None: - """ - :keyword adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. - :paramtype adx_resource_id: str - :keyword adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. - :paramtype adx_endpoint_uri: str - :keyword adx_database_name: The name of the Azure Data Explorer database. Required. - :paramtype adx_database_name: str - :keyword adx_table_name: The name of the Azure Data Explorer table. Defaults to - AdtPropertyEvents. - :paramtype adx_table_name: str - :keyword event_hub_endpoint_uri: The URL of the EventHub namespace for identity-based - authentication. It must include the protocol sb://. Required. - :paramtype event_hub_endpoint_uri: str - :keyword event_hub_entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. Required. - :paramtype event_hub_entity_path: str - :keyword event_hub_namespace_resource_id: The resource ID of the EventHub namespace. Required. - :paramtype event_hub_namespace_resource_id: str - :keyword event_hub_consumer_group: The EventHub consumer group to use when ADX reads from - EventHub. Defaults to $Default. - :paramtype event_hub_consumer_group: str - """ - super().__init__(**kwargs) - self.connection_type: str = "AzureDataExplorer" - self.adx_resource_id = adx_resource_id - self.adx_endpoint_uri = adx_endpoint_uri - self.adx_database_name = adx_database_name - self.adx_table_name = adx_table_name - self.event_hub_endpoint_uri = event_hub_endpoint_uri - self.event_hub_entity_path = event_hub_entity_path - self.event_hub_namespace_resource_id = event_hub_namespace_resource_id - self.event_hub_consumer_group = event_hub_consumer_group - - -class CheckNameRequest(_serialization.Model): - """The result returned from a database check name availability request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. Required. - :vartype name: str - :ivar type: The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. - Required. Default value is "Microsoft.DigitalTwins/digitalTwinsInstances". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.DigitalTwins/digitalTwinsInstances" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Resource name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameResult(_serialization.Model): - """The result returned from a check name availability request. - - :ivar name_available: Specifies a Boolean value that indicates if the name is available. - :vartype name_available: bool - :ivar message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.Reason - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - message: Optional[str] = None, - reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Specifies a Boolean value that indicates if the name is available. - :paramtype name_available: bool - :keyword message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.Reason - """ - super().__init__(**kwargs) - self.name_available = name_available - self.message = message - self.reason = reason - - -class ConnectionProperties(_serialization.Model): - """The properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state. Known values are: "Pending", "Approved", - "Rejected", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionPropertiesProvisioningState - :ivar private_endpoint: The private endpoint. - :vartype private_endpoint: ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpoint - :ivar group_ids: The list of group ids for the private endpoint connection. - :vartype group_ids: list[str] - :ivar private_link_service_connection_state: The connection state. - :vartype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, - "group_ids": {"key": "groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "ConnectionPropertiesPrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - group_ids: Optional[List[str]] = None, - private_link_service_connection_state: Optional[ - "_models.ConnectionPropertiesPrivateLinkServiceConnectionState" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The private endpoint. - :paramtype private_endpoint: ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpoint - :keyword group_ids: The list of group ids for the private endpoint connection. - :paramtype group_ids: list[str] - :keyword private_link_service_connection_state: The connection state. - :paramtype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint = private_endpoint - self.group_ids = group_ids - self.private_link_service_connection_state = private_link_service_connection_state - - -class ConnectionState(_serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): - """The connection state. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(status=status, description=description, actions_required=actions_required, **kwargs) - - -class DigitalTwinsResource(_serialization.Model): - """The common properties of a DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the - DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_05_31.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentity - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.identity = identity - self.system_data = None - - -class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many-instance-attributes - """The description of the DigitalTwins service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the - DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_05_31.models.SystemData - :ivar created_time: Time when DigitalTwinsInstance was created. - :vartype created_time: ~datetime.datetime - :ivar last_updated_time: Time when DigitalTwinsInstance was updated. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - and "Moving". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.ProvisioningState - :ivar host_name: Api endpoint to work with DigitalTwinsInstance. - :vartype host_name: str - :ivar private_endpoint_connections: The private endpoint connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PublicNetworkAccess - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentity - :keyword private_endpoint_connections: The private endpoint connections. - :paramtype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PublicNetworkAccess - """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) - self.created_time = None - self.last_updated_time = None - self.provisioning_state = None - self.host_name = None - self.private_endpoint_connections = private_endpoint_connections - self.public_network_access = public_network_access - - -class DigitalTwinsDescriptionListResult(_serialization.Model): - """A list of DigitalTwins description objects with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins description objects. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsDescription]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsDescription"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - :keyword value: A list of DigitalTwins description objects. - :paramtype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class ExternalResource(_serialization.Model): - """Definition of a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_05_31.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class DigitalTwinsEndpointResource(ExternalResource): - """DigitalTwinsInstance endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_05_31.models.SystemData - :ivar properties: DigitalTwinsInstance endpoint resource properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "DigitalTwinsEndpointResourceProperties"}, - } - - def __init__(self, *, properties: "_models.DigitalTwinsEndpointResourceProperties", **kwargs: Any) -> None: - """ - :keyword properties: DigitalTwinsInstance endpoint resource properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class DigitalTwinsEndpointResourceListResult(_serialization.Model): - """A list of DigitalTwinsInstance Endpoints with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :vartype next_link: str - :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsEndpointResource]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsEndpointResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :paramtype next_link: str - :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class DigitalTwinsEndpointResourceProperties(_serialization.Model): - """Properties related to Digital Twins Endpoint. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventGrid, EventHub, ServiceBus - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - } - - _subtype_map = {"endpoint_type": {"EventGrid": "EventGrid", "EventHub": "EventHub", "ServiceBus": "ServiceBus"}} - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - """ - super().__init__(**kwargs) - self.endpoint_type: Optional[str] = None - self.provisioning_state = None - self.created_time = None - self.authentication_type = authentication_type - self.dead_letter_secret = dead_letter_secret - self.dead_letter_uri = dead_letter_uri - - -class DigitalTwinsIdentity(_serialization.Model): - """The managed identity for the DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned - is supported. Known values are: "None" and "SystemAssigned". - :vartype type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.DigitalTwinsIdentityType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of Managed Identity used by the DigitalTwinsInstance. Only - SystemAssigned is supported. Known values are: "None" and "SystemAssigned". - :paramtype type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentityType - """ - super().__init__(**kwargs) - self.type = type - self.principal_id = None - self.tenant_id = None - - -class DigitalTwinsPatchDescription(_serialization.Model): - """The description of the DigitalTwins service. - - :ivar tags: Instance patch properties. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentity - :ivar properties: Properties for the DigitalTwinsInstance. - :vartype properties: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsPatchProperties - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "DigitalTwinsIdentity"}, - "properties": {"key": "properties", "type": "DigitalTwinsPatchProperties"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.DigitalTwinsIdentity"] = None, - properties: Optional["_models.DigitalTwinsPatchProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Instance patch properties. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsIdentity - :keyword properties: Properties for the DigitalTwinsInstance. - :paramtype properties: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsPatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.properties = properties - - -class DigitalTwinsPatchProperties(_serialization.Model): - """The properties of a DigitalTwinsInstance. - - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PublicNetworkAccess - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, *, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.PublicNetworkAccess - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2022_05_31.models.ErrorDefinition] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2022_05_31.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2022_05_31.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class EventGrid(DigitalTwinsEndpointResourceProperties): - """Properties related to EventGrid. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar topic_endpoint: EventGrid Topic Endpoint. Required. - :vartype topic_endpoint: str - :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key1: str - :ivar access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :vartype access_key2: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "topic_endpoint": {"required": True}, - "access_key1": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "topic_endpoint": {"key": "TopicEndpoint", "type": "str"}, - "access_key1": {"key": "accessKey1", "type": "str"}, - "access_key2": {"key": "accessKey2", "type": "str"}, - } - - def __init__( - self, - *, - topic_endpoint: str, - access_key1: str, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - access_key2: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword topic_endpoint: EventGrid Topic Endpoint. Required. - :paramtype topic_endpoint: str - :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key1: str - :keyword access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :paramtype access_key2: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "EventGrid" - self.topic_endpoint = topic_endpoint - self.access_key1 = access_key1 - self.access_key2 = access_key2 - - -class EventHub(DigitalTwinsEndpointResourceProperties): - """Properties related to EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_primary_key: str - :ivar connection_string_secondary_key: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_secondary_key: str - :ivar endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol 'sb://'. - :vartype endpoint_uri: str - :ivar entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "connection_string_primary_key": {"key": "connectionStringPrimaryKey", "type": "str"}, - "connection_string_secondary_key": {"key": "connectionStringSecondaryKey", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - connection_string_primary_key: Optional[str] = None, - connection_string_secondary_key: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype connection_string_primary_key: str - :keyword connection_string_secondary_key: SecondaryConnectionString of the endpoint for - key-based authentication. Will be obfuscated during read. - :paramtype connection_string_secondary_key: str - :keyword endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol 'sb://'. - :paramtype endpoint_uri: str - :keyword entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "EventHub" - self.connection_string_primary_key = connection_string_primary_key - self.connection_string_secondary_key = connection_string_secondary_key - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class GroupIdInformation(_serialization.Model): - """The group information for creating a private endpoint on Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar properties: The group information properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformationProperties - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "properties": {"required": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - properties: "_models.GroupIdInformationProperties", - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword properties: The group information properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformationProperties - :keyword id: The resource identifier. - :paramtype id: str - """ - super().__init__(**kwargs) - self.properties = properties - self.id = id - self.name = None - self.type = None - - -class GroupIdInformationProperties(_serialization.Model): - """The properties for a group information object. - - :ivar group_id: The group id. - :vartype group_id: str - :ivar required_members: The required members for a specific group id. - :vartype required_members: list[str] - :ivar required_zone_names: The required DNS zones for a specific group id. - :vartype required_zone_names: list[str] - """ - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - required_members: Optional[List[str]] = None, - required_zone_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The group id. - :paramtype group_id: str - :keyword required_members: The required members for a specific group id. - :paramtype required_members: list[str] - :keyword required_zone_names: The required DNS zones for a specific group id. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = group_id - self.required_members = required_members - self.required_zone_names = required_zone_names - - -class GroupIdInformationResponse(_serialization.Model): - """The available private link resources for a Digital Twin. - - :ivar value: The list of available private link resources for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformation] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GroupIdInformation]"}, - } - - def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link resources for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.GroupIdInformation] - """ - super().__init__(**kwargs) - self.value = value - - -class Operation(_serialization.Model): - """DigitalTwins service REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. - :vartype name: str - :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2022_05_31.models.OperationDisplay - :ivar origin: The intended executor of the operation. - :vartype origin: str - :ivar is_data_action: If the operation is a data action (for data plane rbac). - :vartype is_data_action: bool - :ivar properties: Operation properties. - :vartype properties: dict[str, JSON] - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - "is_data_action": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2022_05_31.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.display = display - self.origin = None - self.is_data_action = None - self.properties = None - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft DigitalTwins. - :vartype provider: str - :ivar resource: Resource Type: DigitalTwinsInstances. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Friendly description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of DigitalTwins 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 next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource - provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.Operation] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = None - - -class PrivateEndpoint(_serialization.Model): - """The private endpoint property of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(_serialization.Model): - """The private endpoint connection of a Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: The connection properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionProperties - :ivar system_data: Metadata pertaining to creation and last modification of the private - endpoint connection. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_05_31.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "properties": {"required": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ConnectionProperties"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, properties: "_models.ConnectionProperties", **kwargs: Any) -> None: - """ - :keyword properties: The connection properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2022_05_31.models.ConnectionProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties - self.system_data = None - - -class PrivateEndpointConnectionsResponse(_serialization.Model): - """The available private link connections for a Digital Twin. - - :ivar value: The list of available private link connections for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link connections for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - - -class ServiceBus(DigitalTwinsEndpointResourceProperties): - """Properties related to ServiceBus. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype secondary_connection_string: str - :ivar endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. It - must include the protocol 'sb://'. - :vartype endpoint_uri: str - :ivar entity_path: The ServiceBus Topic name for identity-based authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - primary_connection_string: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype secondary_connection_string: str - :keyword endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. - It must include the protocol 'sb://'. - :paramtype endpoint_uri: str - :keyword entity_path: The ServiceBus Topic name for identity-based authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - **kwargs - ) - self.endpoint_type: str = "ServiceBus" - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.digitaltwins.v2022_05_31.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2022_05_31.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TimeSeriesDatabaseConnection(ExternalResource): - """Describes a time series database connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_05_31.models.SystemData - :ivar properties: Properties of a specific time series database connection. - :vartype properties: - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "TimeSeriesDatabaseConnectionProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.TimeSeriesDatabaseConnectionProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties of a specific time series database connection. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnectionProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class TimeSeriesDatabaseConnectionListResult(_serialization.Model): - """A pageable list of time series database connection resources. - - :ivar next_link: The link used to get the next page of results. - :vartype next_link: str - :ivar value: A list of time series database connection resources. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[TimeSeriesDatabaseConnection]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.TimeSeriesDatabaseConnection"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of results. - :paramtype next_link: str - :keyword value: A list of time series database connection resources. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/__init__.py deleted file mode 100644 index 791d2a1bb74f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._time_series_database_connections_operations import TimeSeriesDatabaseConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "TimeSeriesDatabaseConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index 31a563f727b3..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,784 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_digital_twins_operations.py deleted file mode 100644 index b39cf5ea15bb..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1274 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=3), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_05_31.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index dbb0078f22a7..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,737 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_time_series_database_connections_operations.py deleted file mode 100644 index c84713c176ea..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/operations/_time_series_database_connections_operations.py +++ /dev/null @@ -1,796 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.TimeSeriesDatabaseConnection"]: - """Get all existing time series database connections for this DigitalTwins instance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("TimeSeriesDatabaseConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - """Get the description of an existing time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): - _content = time_series_database_connection_description - else: - _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: _models.TimeSeriesDatabaseConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - time_series_database_connection_description=time_series_database_connection_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Delete a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_05_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-05-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-05-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_05_31/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_azure_digital_twins_management_client.py deleted file mode 100644 index 472f9f45e0a3..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,125 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: azure.mgmt.digitaltwins.v2022_10_31.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2022_10_31.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2022_10_31.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2022_10_31.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2022_10_31.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2022_10_31.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_configuration.py deleted file mode 100644 index 726d8f8d6f28..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", "2022-10-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_metadata.json deleted file mode 100644 index 7e3de7326222..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2022-10-31", - "total_api_version_list": ["2022-10-31"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "time_series_database_connections": "TimeSeriesDatabaseConnectionsOperations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index b66ae3bcc9a4..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2022_10_31.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2022_10_31.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2022_10_31.aio.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2022_10_31.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2022_10_31.aio.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2022_10_31.aio.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - 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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_configuration.py deleted file mode 100644 index 9a00820f754f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", "2022-10-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/__init__.py deleted file mode 100644 index 791d2a1bb74f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._time_series_database_connections_operations import TimeSeriesDatabaseConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "TimeSeriesDatabaseConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_digital_twins_operations.py deleted file mode 100644 index 49853b010234..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1029 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_operations import ( - build_check_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, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_operations.py deleted file mode 100644 index a4b820a4a03a..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 92b7d69ca668..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,187 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_resources_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_time_series_database_connections_operations.py deleted file mode 100644 index 45d613aa5d5f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/aio/operations/_time_series_database_connections_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._time_series_database_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TimeSeriesDatabaseConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`time_series_database_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.TimeSeriesDatabaseConnection"]: - """Get all existing time series database connections for this DigitalTwins instance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("TimeSeriesDatabaseConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - """Get the description of an existing time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): - _content = time_series_database_connection_description - else: - _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: _models.TimeSeriesDatabaseConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - time_series_database_connection_description=time_series_database_connection_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.TimeSeriesDatabaseConnection]: - """Delete a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/__init__.py deleted file mode 100644 index 91711000ace2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/__init__.py +++ /dev/null @@ -1,115 +0,0 @@ -# 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 AzureDataExplorerConnectionProperties -from ._models_py3 import CheckNameRequest -from ._models_py3 import CheckNameResult -from ._models_py3 import ConnectionProperties -from ._models_py3 import ConnectionPropertiesPrivateLinkServiceConnectionState -from ._models_py3 import ConnectionState -from ._models_py3 import DigitalTwinsDescription -from ._models_py3 import DigitalTwinsDescriptionListResult -from ._models_py3 import DigitalTwinsEndpointResource -from ._models_py3 import DigitalTwinsEndpointResourceListResult -from ._models_py3 import DigitalTwinsEndpointResourceProperties -from ._models_py3 import DigitalTwinsIdentity -from ._models_py3 import DigitalTwinsPatchDescription -from ._models_py3 import DigitalTwinsPatchProperties -from ._models_py3 import DigitalTwinsResource -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorResponse -from ._models_py3 import EventGrid -from ._models_py3 import EventHub -from ._models_py3 import ExternalResource -from ._models_py3 import GroupIdInformation -from ._models_py3 import GroupIdInformationProperties -from ._models_py3 import GroupIdInformationResponse -from ._models_py3 import ManagedIdentityReference -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionsResponse -from ._models_py3 import ServiceBus -from ._models_py3 import SystemData -from ._models_py3 import TimeSeriesDatabaseConnection -from ._models_py3 import TimeSeriesDatabaseConnectionListResult -from ._models_py3 import TimeSeriesDatabaseConnectionProperties -from ._models_py3 import UserAssignedIdentity - -from ._azure_digital_twins_management_client_enums import AuthenticationType -from ._azure_digital_twins_management_client_enums import ConnectionPropertiesProvisioningState -from ._azure_digital_twins_management_client_enums import ConnectionType -from ._azure_digital_twins_management_client_enums import CreatedByType -from ._azure_digital_twins_management_client_enums import DigitalTwinsIdentityType -from ._azure_digital_twins_management_client_enums import EndpointProvisioningState -from ._azure_digital_twins_management_client_enums import EndpointType -from ._azure_digital_twins_management_client_enums import IdentityType -from ._azure_digital_twins_management_client_enums import PrivateLinkServiceConnectionStatus -from ._azure_digital_twins_management_client_enums import ProvisioningState -from ._azure_digital_twins_management_client_enums import PublicNetworkAccess -from ._azure_digital_twins_management_client_enums import Reason -from ._azure_digital_twins_management_client_enums import TimeSeriesDatabaseConnectionState -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDataExplorerConnectionProperties", - "CheckNameRequest", - "CheckNameResult", - "ConnectionProperties", - "ConnectionPropertiesPrivateLinkServiceConnectionState", - "ConnectionState", - "DigitalTwinsDescription", - "DigitalTwinsDescriptionListResult", - "DigitalTwinsEndpointResource", - "DigitalTwinsEndpointResourceListResult", - "DigitalTwinsEndpointResourceProperties", - "DigitalTwinsIdentity", - "DigitalTwinsPatchDescription", - "DigitalTwinsPatchProperties", - "DigitalTwinsResource", - "ErrorDefinition", - "ErrorResponse", - "EventGrid", - "EventHub", - "ExternalResource", - "GroupIdInformation", - "GroupIdInformationProperties", - "GroupIdInformationResponse", - "ManagedIdentityReference", - "Operation", - "OperationDisplay", - "OperationListResult", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionsResponse", - "ServiceBus", - "SystemData", - "TimeSeriesDatabaseConnection", - "TimeSeriesDatabaseConnectionListResult", - "TimeSeriesDatabaseConnectionProperties", - "UserAssignedIdentity", - "AuthenticationType", - "ConnectionPropertiesProvisioningState", - "ConnectionType", - "CreatedByType", - "DigitalTwinsIdentityType", - "EndpointProvisioningState", - "EndpointType", - "IdentityType", - "PrivateLinkServiceConnectionStatus", - "ProvisioningState", - "PublicNetworkAccess", - "Reason", - "TimeSeriesDatabaseConnectionState", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_azure_digital_twins_management_client_enums.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_azure_digital_twins_management_client_enums.py deleted file mode 100644 index ec2b72e3b19f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_azure_digital_twins_management_client_enums.py +++ /dev/null @@ -1,142 +0,0 @@ -# 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 azure.core import CaseInsensitiveEnumMeta - - -class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the authentication type being used for connecting to the endpoint. Defaults to - 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the - primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath - properties must be specified. - """ - - KEY_BASED = "KeyBased" - IDENTITY_BASED = "IdentityBased" - - -class ConnectionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of time series connection resource.""" - - AZURE_DATA_EXPLORER = "AzureDataExplorer" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DigitalTwinsIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DigitalTwinsInstance.""" - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" - - -class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" - - -class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Digital Twins endpoint.""" - - EVENT_HUB = "EventHub" - EVENT_GRID = "EventGrid" - SERVICE_BUS = "ServiceBus" - - -class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of managed identity used.""" - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - - -class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of a private endpoint connection.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Public network access for the DigitalTwinsInstance.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Message providing the reason why the given name is invalid.""" - - INVALID = "Invalid" - ALREADY_EXISTS = "AlreadyExists" - - -class TimeSeriesDatabaseConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state.""" - - PROVISIONING = "Provisioning" - DELETING = "Deleting" - UPDATING = "Updating" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - DELETED = "Deleted" - WARNING = "Warning" - SUSPENDING = "Suspending" - RESTORING = "Restoring" - MOVING = "Moving" - DISABLED = "Disabled" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_models_py3.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_models_py3.py deleted file mode 100644 index 0ee037c1f245..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_models_py3.py +++ /dev/null @@ -1,1879 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class TimeSeriesDatabaseConnectionProperties(_serialization.Model): - """Properties of a time series database connection resource. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureDataExplorerConnectionProperties - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar connection_type: The type of time series connection resource. Required. - "AzureDataExplorer" - :vartype connection_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnectionState - :ivar identity: Managed identity properties for the time series database connection resource. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - """ - - _validation = { - "connection_type": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "connection_type": {"key": "connectionType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentityReference"}, - } - - _subtype_map = {"connection_type": {"AzureDataExplorer": "AzureDataExplorerConnectionProperties"}} - - def __init__(self, *, identity: Optional["_models.ManagedIdentityReference"] = None, **kwargs: Any) -> None: - """ - :keyword identity: Managed identity properties for the time series database connection - resource. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - """ - super().__init__(**kwargs) - self.connection_type: Optional[str] = None - self.provisioning_state = None - self.identity = identity - - -class AzureDataExplorerConnectionProperties( - TimeSeriesDatabaseConnectionProperties -): # pylint: disable=too-many-instance-attributes - """Properties of a time series database connection to Azure Data Explorer with data being sent via - an EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar connection_type: The type of time series connection resource. Required. - "AzureDataExplorer" - :vartype connection_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnectionState - :ivar identity: Managed identity properties for the time series database connection resource. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :ivar adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. - :vartype adx_resource_id: str - :ivar adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. - :vartype adx_endpoint_uri: str - :ivar adx_database_name: The name of the Azure Data Explorer database. Required. - :vartype adx_database_name: str - :ivar adx_table_name: The name of the Azure Data Explorer table. Defaults to AdtPropertyEvents. - :vartype adx_table_name: str - :ivar event_hub_endpoint_uri: The URL of the EventHub namespace for identity-based - authentication. It must include the protocol sb://. Required. - :vartype event_hub_endpoint_uri: str - :ivar event_hub_entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. Required. - :vartype event_hub_entity_path: str - :ivar event_hub_namespace_resource_id: The resource ID of the EventHub namespace. Required. - :vartype event_hub_namespace_resource_id: str - :ivar event_hub_consumer_group: The EventHub consumer group to use when ADX reads from - EventHub. Defaults to $Default. - :vartype event_hub_consumer_group: str - """ - - _validation = { - "connection_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "adx_resource_id": {"required": True}, - "adx_endpoint_uri": {"required": True}, - "adx_database_name": {"required": True}, - "event_hub_endpoint_uri": {"required": True}, - "event_hub_entity_path": {"required": True}, - "event_hub_namespace_resource_id": {"required": True}, - } - - _attribute_map = { - "connection_type": {"key": "connectionType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentityReference"}, - "adx_resource_id": {"key": "adxResourceId", "type": "str"}, - "adx_endpoint_uri": {"key": "adxEndpointUri", "type": "str"}, - "adx_database_name": {"key": "adxDatabaseName", "type": "str"}, - "adx_table_name": {"key": "adxTableName", "type": "str"}, - "event_hub_endpoint_uri": {"key": "eventHubEndpointUri", "type": "str"}, - "event_hub_entity_path": {"key": "eventHubEntityPath", "type": "str"}, - "event_hub_namespace_resource_id": {"key": "eventHubNamespaceResourceId", "type": "str"}, - "event_hub_consumer_group": {"key": "eventHubConsumerGroup", "type": "str"}, - } - - def __init__( - self, - *, - adx_resource_id: str, - adx_endpoint_uri: str, - adx_database_name: str, - event_hub_endpoint_uri: str, - event_hub_entity_path: str, - event_hub_namespace_resource_id: str, - identity: Optional["_models.ManagedIdentityReference"] = None, - adx_table_name: str = "AdtPropertyEvents", - event_hub_consumer_group: str = "$Default", - **kwargs: Any - ) -> None: - """ - :keyword identity: Managed identity properties for the time series database connection - resource. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :keyword adx_resource_id: The resource ID of the Azure Data Explorer cluster. Required. - :paramtype adx_resource_id: str - :keyword adx_endpoint_uri: The URI of the Azure Data Explorer endpoint. Required. - :paramtype adx_endpoint_uri: str - :keyword adx_database_name: The name of the Azure Data Explorer database. Required. - :paramtype adx_database_name: str - :keyword adx_table_name: The name of the Azure Data Explorer table. Defaults to - AdtPropertyEvents. - :paramtype adx_table_name: str - :keyword event_hub_endpoint_uri: The URL of the EventHub namespace for identity-based - authentication. It must include the protocol sb://. Required. - :paramtype event_hub_endpoint_uri: str - :keyword event_hub_entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. Required. - :paramtype event_hub_entity_path: str - :keyword event_hub_namespace_resource_id: The resource ID of the EventHub namespace. Required. - :paramtype event_hub_namespace_resource_id: str - :keyword event_hub_consumer_group: The EventHub consumer group to use when ADX reads from - EventHub. Defaults to $Default. - :paramtype event_hub_consumer_group: str - """ - super().__init__(identity=identity, **kwargs) - self.connection_type: str = "AzureDataExplorer" - self.adx_resource_id = adx_resource_id - self.adx_endpoint_uri = adx_endpoint_uri - self.adx_database_name = adx_database_name - self.adx_table_name = adx_table_name - self.event_hub_endpoint_uri = event_hub_endpoint_uri - self.event_hub_entity_path = event_hub_entity_path - self.event_hub_namespace_resource_id = event_hub_namespace_resource_id - self.event_hub_consumer_group = event_hub_consumer_group - - -class CheckNameRequest(_serialization.Model): - """The result returned from a database check name availability request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. Required. - :vartype name: str - :ivar type: The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. - Required. Default value is "Microsoft.DigitalTwins/digitalTwinsInstances". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.DigitalTwins/digitalTwinsInstances" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Resource name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameResult(_serialization.Model): - """The result returned from a check name availability request. - - :ivar name_available: Specifies a Boolean value that indicates if the name is available. - :vartype name_available: bool - :ivar message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.Reason - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - message: Optional[str] = None, - reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Specifies a Boolean value that indicates if the name is available. - :paramtype name_available: bool - :keyword message: Message indicating an unavailable name due to a conflict, or a description of - the naming rules that are violated. - :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Known values are: - "Invalid" and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.Reason - """ - super().__init__(**kwargs) - self.name_available = name_available - self.message = message - self.reason = reason - - -class ConnectionProperties(_serialization.Model): - """The properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state. Known values are: "Pending", "Approved", - "Rejected", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionPropertiesProvisioningState - :ivar private_endpoint: The private endpoint. - :vartype private_endpoint: ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpoint - :ivar group_ids: The list of group ids for the private endpoint connection. - :vartype group_ids: list[str] - :ivar private_link_service_connection_state: The connection state. - :vartype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, - "group_ids": {"key": "groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "ConnectionPropertiesPrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - group_ids: Optional[List[str]] = None, - private_link_service_connection_state: Optional[ - "_models.ConnectionPropertiesPrivateLinkServiceConnectionState" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The private endpoint. - :paramtype private_endpoint: ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpoint - :keyword group_ids: The list of group ids for the private endpoint connection. - :paramtype group_ids: list[str] - :keyword private_link_service_connection_state: The connection state. - :paramtype private_link_service_connection_state: - ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionPropertiesPrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint = private_endpoint - self.group_ids = group_ids - self.private_link_service_connection_state = private_link_service_connection_state - - -class ConnectionState(_serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ConnectionPropertiesPrivateLinkServiceConnectionState(ConnectionState): - """The connection state. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateLinkServiceConnectionStatus - :ivar description: The description for the current state of a private endpoint connection. - Required. - :vartype description: str - :ivar actions_required: Actions required for a private endpoint connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], - description: str, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: The status of a private endpoint connection. Required. Known values are: - "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateLinkServiceConnectionStatus - :keyword description: The description for the current state of a private endpoint connection. - Required. - :paramtype description: str - :keyword actions_required: Actions required for a private endpoint connection. - :paramtype actions_required: str - """ - super().__init__(status=status, description=description, actions_required=actions_required, **kwargs) - - -class DigitalTwinsResource(_serialization.Model): - """The common properties of a DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the - DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_10_31.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentity - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.identity = identity - self.system_data = None - - -class DigitalTwinsDescription(DigitalTwinsResource): # pylint: disable=too-many-instance-attributes - """The description of the DigitalTwins service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar location: The resource location. Required. - :vartype location: str - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the - DigitalTwinsInstance. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_10_31.models.SystemData - :ivar created_time: Time when DigitalTwinsInstance was created. - :vartype created_time: ~datetime.datetime - :ivar last_updated_time: Time when DigitalTwinsInstance was updated. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - and "Moving". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.ProvisioningState - :ivar host_name: Api endpoint to work with DigitalTwinsInstance. - :vartype host_name: str - :ivar private_endpoint_connections: The private endpoint connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PublicNetworkAccess - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?!-)[A-Za-z0-9-]{3,63}(? None: - """ - :keyword location: The resource location. Required. - :paramtype location: str - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentity - :keyword private_endpoint_connections: The private endpoint connections. - :paramtype private_endpoint_connections: - list[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PublicNetworkAccess - """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) - self.created_time = None - self.last_updated_time = None - self.provisioning_state = None - self.host_name = None - self.private_endpoint_connections = private_endpoint_connections - self.public_network_access = public_network_access - - -class DigitalTwinsDescriptionListResult(_serialization.Model): - """A list of DigitalTwins description objects with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins description objects. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsDescription]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsDescription"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - :keyword value: A list of DigitalTwins description objects. - :paramtype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class ExternalResource(_serialization.Model): - """Definition of a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_10_31.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class DigitalTwinsEndpointResource(ExternalResource): - """DigitalTwinsInstance endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_10_31.models.SystemData - :ivar properties: DigitalTwinsInstance endpoint resource properties. Required. - :vartype properties: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "DigitalTwinsEndpointResourceProperties"}, - } - - def __init__(self, *, properties: "_models.DigitalTwinsEndpointResourceProperties", **kwargs: Any) -> None: - """ - :keyword properties: DigitalTwinsInstance endpoint resource properties. Required. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class DigitalTwinsEndpointResourceListResult(_serialization.Model): - """A list of DigitalTwinsInstance Endpoints with a next link. - - :ivar next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :vartype next_link: str - :ivar value: A list of DigitalTwinsInstance Endpoints. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[DigitalTwinsEndpointResource]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.DigitalTwinsEndpointResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwinsInstance Endpoints. - :paramtype next_link: str - :keyword value: A list of DigitalTwinsInstance Endpoints. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsEndpointResource] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class DigitalTwinsEndpointResourceProperties(_serialization.Model): - """Properties related to Digital Twins Endpoint. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventGrid, EventHub, ServiceBus - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentityReference"}, - } - - _subtype_map = {"endpoint_type": {"EventGrid": "EventGrid", "EventHub": "EventHub", "ServiceBus": "ServiceBus"}} - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - identity: Optional["_models.ManagedIdentityReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - """ - super().__init__(**kwargs) - self.endpoint_type: Optional[str] = None - self.provisioning_state = None - self.created_time = None - self.authentication_type = authentication_type - self.dead_letter_secret = dead_letter_secret - self.dead_letter_uri = dead_letter_uri - self.identity = identity - - -class DigitalTwinsIdentity(_serialization.Model): - """The managed identity for the DigitalTwinsInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DigitalTwinsInstance. Known values are: - "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - :ivar user_assigned_identities: The list of user identities associated with the resource. The - user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - . - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.digitaltwins.v2022_10_31.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.DigitalTwinsIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DigitalTwinsInstance. Known values are: - "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentityType - :keyword user_assigned_identities: The list of user identities associated with the resource. - The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - . - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.digitaltwins.v2022_10_31.models.UserAssignedIdentity] - """ - super().__init__(**kwargs) - self.type = type - self.principal_id = None - self.tenant_id = None - self.user_assigned_identities = user_assigned_identities - - -class DigitalTwinsPatchDescription(_serialization.Model): - """The description of the DigitalTwins service. - - :ivar tags: Instance patch properties. - :vartype tags: dict[str, str] - :ivar identity: The managed identity for the DigitalTwinsInstance. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentity - :ivar properties: Properties for the DigitalTwinsInstance. - :vartype properties: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsPatchProperties - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "DigitalTwinsIdentity"}, - "properties": {"key": "properties", "type": "DigitalTwinsPatchProperties"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.DigitalTwinsIdentity"] = None, - properties: Optional["_models.DigitalTwinsPatchProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Instance patch properties. - :paramtype tags: dict[str, str] - :keyword identity: The managed identity for the DigitalTwinsInstance. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsIdentity - :keyword properties: Properties for the DigitalTwinsInstance. - :paramtype properties: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsPatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.properties = properties - - -class DigitalTwinsPatchProperties(_serialization.Model): - """The properties of a DigitalTwinsInstance. - - :ivar public_network_access: Public network access for the DigitalTwinsInstance. Known values - are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PublicNetworkAccess - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, *, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Public network access for the DigitalTwinsInstance. Known - values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.PublicNetworkAccess - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.digitaltwins.v2022_10_31.models.ErrorDefinition] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: Error description. - :vartype error: ~azure.mgmt.digitaltwins.v2022_10_31.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error description. - :paramtype error: ~azure.mgmt.digitaltwins.v2022_10_31.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class EventGrid(DigitalTwinsEndpointResourceProperties): - """Properties related to EventGrid. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :ivar topic_endpoint: EventGrid Topic Endpoint. Required. - :vartype topic_endpoint: str - :ivar access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :vartype access_key1: str - :ivar access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :vartype access_key2: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - "topic_endpoint": {"required": True}, - "access_key1": {"required": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentityReference"}, - "topic_endpoint": {"key": "TopicEndpoint", "type": "str"}, - "access_key1": {"key": "accessKey1", "type": "str"}, - "access_key2": {"key": "accessKey2", "type": "str"}, - } - - def __init__( - self, - *, - topic_endpoint: str, - access_key1: str, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - identity: Optional["_models.ManagedIdentityReference"] = None, - access_key2: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :keyword topic_endpoint: EventGrid Topic Endpoint. Required. - :paramtype topic_endpoint: str - :keyword access_key1: EventGrid secondary accesskey. Will be obfuscated during read. Required. - :paramtype access_key1: str - :keyword access_key2: EventGrid secondary accesskey. Will be obfuscated during read. - :paramtype access_key2: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - identity=identity, - **kwargs - ) - self.endpoint_type: str = "EventGrid" - self.topic_endpoint = topic_endpoint - self.access_key1 = access_key1 - self.access_key2 = access_key2 - - -class EventHub(DigitalTwinsEndpointResourceProperties): # pylint: disable=too-many-instance-attributes - """Properties related to EventHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :ivar connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_primary_key: str - :ivar connection_string_secondary_key: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype connection_string_secondary_key: str - :ivar endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol 'sb://'. - :vartype endpoint_uri: str - :ivar entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentityReference"}, - "connection_string_primary_key": {"key": "connectionStringPrimaryKey", "type": "str"}, - "connection_string_secondary_key": {"key": "connectionStringSecondaryKey", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - identity: Optional["_models.ManagedIdentityReference"] = None, - connection_string_primary_key: Optional[str] = None, - connection_string_secondary_key: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :keyword connection_string_primary_key: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype connection_string_primary_key: str - :keyword connection_string_secondary_key: SecondaryConnectionString of the endpoint for - key-based authentication. Will be obfuscated during read. - :paramtype connection_string_secondary_key: str - :keyword endpoint_uri: The URL of the EventHub namespace for identity-based authentication. It - must include the protocol 'sb://'. - :paramtype endpoint_uri: str - :keyword entity_path: The EventHub name in the EventHub namespace for identity-based - authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - identity=identity, - **kwargs - ) - self.endpoint_type: str = "EventHub" - self.connection_string_primary_key = connection_string_primary_key - self.connection_string_secondary_key = connection_string_secondary_key - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class GroupIdInformation(_serialization.Model): - """The group information for creating a private endpoint on Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar properties: The group information properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformationProperties - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "properties": {"required": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - properties: "_models.GroupIdInformationProperties", - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword properties: The group information properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformationProperties - :keyword id: The resource identifier. - :paramtype id: str - """ - super().__init__(**kwargs) - self.properties = properties - self.id = id - self.name = None - self.type = None - - -class GroupIdInformationProperties(_serialization.Model): - """The properties for a group information object. - - :ivar group_id: The group id. - :vartype group_id: str - :ivar required_members: The required members for a specific group id. - :vartype required_members: list[str] - :ivar required_zone_names: The required DNS zones for a specific group id. - :vartype required_zone_names: list[str] - """ - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - required_members: Optional[List[str]] = None, - required_zone_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The group id. - :paramtype group_id: str - :keyword required_members: The required members for a specific group id. - :paramtype required_members: list[str] - :keyword required_zone_names: The required DNS zones for a specific group id. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = group_id - self.required_members = required_members - self.required_zone_names = required_zone_names - - -class GroupIdInformationResponse(_serialization.Model): - """The available private link resources for a Digital Twin. - - :ivar value: The list of available private link resources for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformation] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GroupIdInformation]"}, - } - - def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link resources for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformation] - """ - super().__init__(**kwargs) - self.value = value - - -class ManagedIdentityReference(_serialization.Model): - """The properties of the Managed Identity. - - :ivar type: The type of managed identity used. Known values are: "SystemAssigned" and - "UserAssigned". - :vartype type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.IdentityType - :ivar user_assigned_identity: The user identity ARM resource id if the managed identity type is - 'UserAssigned'. - :vartype user_assigned_identity: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.IdentityType"]] = None, - user_assigned_identity: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of managed identity used. Known values are: "SystemAssigned" and - "UserAssigned". - :paramtype type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.IdentityType - :keyword user_assigned_identity: The user identity ARM resource id if the managed identity type - is 'UserAssigned'. - :paramtype user_assigned_identity: str - """ - super().__init__(**kwargs) - self.type = type - self.user_assigned_identity = user_assigned_identity - - -class Operation(_serialization.Model): - """DigitalTwins service REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. - :vartype name: str - :ivar display: Operation properties display. - :vartype display: ~azure.mgmt.digitaltwins.v2022_10_31.models.OperationDisplay - :ivar origin: The intended executor of the operation. - :vartype origin: str - :ivar is_data_action: If the operation is a data action (for data plane rbac). - :vartype is_data_action: bool - :ivar properties: Operation properties. - :vartype properties: dict[str, JSON] - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - "is_data_action": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Operation properties display. - :paramtype display: ~azure.mgmt.digitaltwins.v2022_10_31.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.display = display - self.origin = None - self.is_data_action = None - self.properties = None - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft DigitalTwins. - :vartype provider: str - :ivar resource: Resource Type: DigitalTwinsInstances. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Friendly description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of DigitalTwins 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 next_link: The link used to get the next page of DigitalTwins description objects. - :vartype next_link: str - :ivar value: A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource - provider. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.Operation] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link used to get the next page of DigitalTwins description objects. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = None - - -class PrivateEndpoint(_serialization.Model): - """The private endpoint property of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(_serialization.Model): - """The private endpoint connection of a Digital Twin. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar properties: The connection properties. Required. - :vartype properties: ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionProperties - :ivar system_data: Metadata pertaining to creation and last modification of the private - endpoint connection. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_10_31.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "properties": {"required": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ConnectionProperties"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, properties: "_models.ConnectionProperties", **kwargs: Any) -> None: - """ - :keyword properties: The connection properties. Required. - :paramtype properties: ~azure.mgmt.digitaltwins.v2022_10_31.models.ConnectionProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties - self.system_data = None - - -class PrivateEndpointConnectionsResponse(_serialization.Model): - """The available private link connections for a Digital Twin. - - :ivar value: The list of available private link connections for a Digital Twin. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of available private link connections for a Digital Twin. - :paramtype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - - -class ServiceBus(DigitalTwinsEndpointResourceProperties): # pylint: disable=too-many-instance-attributes - """Properties related to ServiceBus. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar endpoint_type: The type of Digital Twins endpoint. Required. Known values are: - "EventHub", "EventGrid", and "ServiceBus". - :vartype endpoint_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointType - :ivar provisioning_state: The provisioning state. Known values are: "Provisioning", "Deleting", - "Updating", "Succeeded", "Failed", "Canceled", "Deleted", "Warning", "Suspending", "Restoring", - "Moving", and "Disabled". - :vartype provisioning_state: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.EndpointProvisioningState - :ivar created_time: Time when the Endpoint was added to DigitalTwinsInstance. - :vartype created_time: ~datetime.datetime - :ivar authentication_type: Specifies the authentication type being used for connecting to the - endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :vartype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :ivar dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :vartype dead_letter_secret: str - :ivar dead_letter_uri: Dead letter storage URL for identity-based authentication. - :vartype dead_letter_uri: str - :ivar identity: Managed identity properties for the endpoint. - :vartype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :ivar primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :vartype secondary_connection_string: str - :ivar endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. It - must include the protocol 'sb://'. - :vartype endpoint_uri: str - :ivar entity_path: The ServiceBus Topic name for identity-based authentication. - :vartype entity_path: str - """ - - _validation = { - "endpoint_type": {"required": True}, - "provisioning_state": {"readonly": True}, - "created_time": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "endpointType", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "dead_letter_secret": {"key": "deadLetterSecret", "type": "str"}, - "dead_letter_uri": {"key": "deadLetterUri", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentityReference"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - "endpoint_uri": {"key": "endpointUri", "type": "str"}, - "entity_path": {"key": "entityPath", "type": "str"}, - } - - def __init__( - self, - *, - authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, - dead_letter_secret: Optional[str] = None, - dead_letter_uri: Optional[str] = None, - identity: Optional["_models.ManagedIdentityReference"] = None, - primary_connection_string: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - endpoint_uri: Optional[str] = None, - entity_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authentication_type: Specifies the authentication type being used for connecting to - the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be - specified (at least the primary connection string). If 'IdentityBased' is select, the - endpointUri and entityPath properties must be specified. Known values are: "KeyBased" and - "IdentityBased". - :paramtype authentication_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.AuthenticationType - :keyword dead_letter_secret: Dead letter storage secret for key-based authentication. Will be - obfuscated during read. - :paramtype dead_letter_secret: str - :keyword dead_letter_uri: Dead letter storage URL for identity-based authentication. - :paramtype dead_letter_uri: str - :keyword identity: Managed identity properties for the endpoint. - :paramtype identity: ~azure.mgmt.digitaltwins.v2022_10_31.models.ManagedIdentityReference - :keyword primary_connection_string: PrimaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the endpoint for key-based - authentication. Will be obfuscated during read. - :paramtype secondary_connection_string: str - :keyword endpoint_uri: The URL of the ServiceBus namespace for identity-based authentication. - It must include the protocol 'sb://'. - :paramtype endpoint_uri: str - :keyword entity_path: The ServiceBus Topic name for identity-based authentication. - :paramtype entity_path: str - """ - super().__init__( - authentication_type=authentication_type, - dead_letter_secret=dead_letter_secret, - dead_letter_uri=dead_letter_uri, - identity=identity, - **kwargs - ) - self.endpoint_type: str = "ServiceBus" - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string - self.endpoint_uri = endpoint_uri - self.entity_path = entity_path - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.digitaltwins.v2022_10_31.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.digitaltwins.v2022_10_31.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TimeSeriesDatabaseConnection(ExternalResource): - """Describes a time series database connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: Extension resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.digitaltwins.v2022_10_31.models.SystemData - :ivar properties: Properties of a specific time series database connection. - :vartype properties: - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "TimeSeriesDatabaseConnectionProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.TimeSeriesDatabaseConnectionProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties of a specific time series database connection. - :paramtype properties: - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnectionProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class TimeSeriesDatabaseConnectionListResult(_serialization.Model): - """A pageable list of time series database connection resources. - - :ivar next_link: The link used to get the next page of results. - :vartype next_link: str - :ivar value: A list of time series database connection resources. - :vartype value: list[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - """ - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[TimeSeriesDatabaseConnection]"}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["_models.TimeSeriesDatabaseConnection"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword next_link: The link used to get the next page of results. - :paramtype next_link: str - :keyword value: A list of time series database connection resources. - :paramtype value: - list[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - """ - super().__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class UserAssignedIdentity(_serialization.Model): - """The information about the user assigned identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar client_id: The client id of the User Assigned Identity Resource. - :vartype client_id: str - :ivar principal_id: The object id of the User Assigned Identity Resource. - :vartype principal_id: str - """ - - _validation = { - "client_id": {"readonly": True}, - "principal_id": {"readonly": True}, - } - - _attribute_map = { - "client_id": {"key": "clientId", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.client_id = None - self.principal_id = None diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/__init__.py deleted file mode 100644 index 791d2a1bb74f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._time_series_database_connections_operations import TimeSeriesDatabaseConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "TimeSeriesDatabaseConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_digital_twins_operations.py deleted file mode 100644 index 95135cd22662..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1274 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=3), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_operations.py deleted file mode 100644 index 08bdabe1dc0c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DigitalTwins/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2022_10_31.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 2a4c3b3e93a0..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,737 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_private_link_resources_operations.py deleted file mode 100644 index 351bab137dcc..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,269 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_time_series_database_connections_operations.py deleted file mode 100644 index 2ae17d792f62..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/operations/_time_series_database_connections_operations.py +++ /dev/null @@ -1,796 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.TimeSeriesDatabaseConnection"]: - """Get all existing time series database connections for this DigitalTwins instance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TimeSeriesDatabaseConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("TimeSeriesDatabaseConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - """Get the description of an existing time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TimeSeriesDatabaseConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> _models.TimeSeriesDatabaseConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(time_series_database_connection_description, (IO, bytes)): - _content = time_series_database_connection_description - else: - _json = self._serialize.body(time_series_database_connection_description, "TimeSeriesDatabaseConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: _models.TimeSeriesDatabaseConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Required. - :type time_series_database_connection_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - time_series_database_connection_name: str, - time_series_database_connection_description: Union[_models.TimeSeriesDatabaseConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Create or update a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :param time_series_database_connection_description: The time series database connection - description. Is either a TimeSeriesDatabaseConnection type or a IO type. Required. - :type time_series_database_connection_description: - ~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - time_series_database_connection_description=time_series_database_connection_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> Optional[_models.TimeSeriesDatabaseConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[Optional[_models.TimeSeriesDatabaseConnection]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, time_series_database_connection_name: str, **kwargs: Any - ) -> LROPoller[_models.TimeSeriesDatabaseConnection]: - """Delete a time series database connection. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param time_series_database_connection_name: Name of time series database connection. Required. - :type time_series_database_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TimeSeriesDatabaseConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2022_10_31.models.TimeSeriesDatabaseConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-31")) - cls: ClsType[_models.TimeSeriesDatabaseConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - time_series_database_connection_name=time_series_database_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TimeSeriesDatabaseConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2022_10_31/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/__init__.py deleted file mode 100644 index 3d416a868dd2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_azure_digital_twins_management_client.py deleted file mode 100644 index 23904845a600..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,125 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: azure.mgmt.digitaltwins.v2023_01_31.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2023_01_31.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2023_01_31.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2023_01_31.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2023_01_31.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2023_01_31.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: 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/dpcodegen/python/send_request - - :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) -> None: - self._client.close() - - def __enter__(self) -> "AzureDigitalTwinsManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_configuration.py deleted file mode 100644 index 0cab25a557d6..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", "2023-01-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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.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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_metadata.json b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_metadata.json deleted file mode 100644 index 49883739b9c3..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2023-01-31", - "total_api_version_list": ["2023-01-31"], - "client": { - "name": "AzureDigitalTwinsManagementClient", - "filename": "_azure_digital_twins_management_client", - "description": "Azure Digital Twins Client for managing DigitalTwinsInstance.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureDigitalTwinsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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": { - "digital_twins": "DigitalTwinsOperations", - "digital_twins_endpoint": "DigitalTwinsEndpointOperations", - "operations": "Operations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "time_series_database_connections": "TimeSeriesDatabaseConnectionsOperations" - } -} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_vendor.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_version.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_version.py deleted file mode 100644 index fba0344fbc7b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "6.4.0" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/__init__.py deleted file mode 100644 index e4da5a5dc30c..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureDigitalTwinsManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_azure_digital_twins_management_client.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_azure_digital_twins_management_client.py deleted file mode 100644 index 43505467acea..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_azure_digital_twins_management_client.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AzureDigitalTwinsManagementClientConfiguration -from .operations import ( - DigitalTwinsEndpointOperations, - DigitalTwinsOperations, - Operations, - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - TimeSeriesDatabaseConnectionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure Digital Twins Client for managing DigitalTwinsInstance. - - :ivar digital_twins: DigitalTwinsOperations operations - :vartype digital_twins: - azure.mgmt.digitaltwins.v2023_01_31.aio.operations.DigitalTwinsOperations - :ivar digital_twins_endpoint: DigitalTwinsEndpointOperations operations - :vartype digital_twins_endpoint: - azure.mgmt.digitaltwins.v2023_01_31.aio.operations.DigitalTwinsEndpointOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.digitaltwins.v2023_01_31.aio.operations.Operations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.digitaltwins.v2023_01_31.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.digitaltwins.v2023_01_31.aio.operations.PrivateEndpointConnectionsOperations - :ivar time_series_database_connections: TimeSeriesDatabaseConnectionsOperations operations - :vartype time_series_database_connections: - azure.mgmt.digitaltwins.v2023_01_31.aio.operations.TimeSeriesDatabaseConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AzureDigitalTwinsManagementClientConfiguration( - 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.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize) - self.digital_twins_endpoint = DigitalTwinsEndpointOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_series_database_connections = TimeSeriesDatabaseConnectionsOperations( - 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/dpcodegen/python/send_request - - :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) -> "AzureDigitalTwinsManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_configuration.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_configuration.py deleted file mode 100644 index d457d81324d3..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_configuration.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 sys -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 sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AzureDigitalTwinsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AzureDigitalTwinsManagementClient. - - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", "2023-01-31") - - 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 = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-digitaltwins/{}".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/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/__init__.py deleted file mode 100644 index 791d2a1bb74f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._time_series_database_connections_operations import TimeSeriesDatabaseConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "TimeSeriesDatabaseConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index fc732167bcf2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_endpoint_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsEndpointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins_endpoint` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_digital_twins_operations.py deleted file mode 100644 index 5f40ce6c3699..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1029 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._digital_twins_operations import ( - build_check_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, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DigitalTwinsDescription or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_operations.py deleted file mode 100644 index 2a842c7f246b..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 5534f2b9f200..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,555 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.aio.AzureDigitalTwinsManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionsResponse: - """List private endpoint connection properties. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionsResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnectionsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.PrivateEndpointConnectionsResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get private endpoint connection properties for the given private endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete private endpoint connection with the specified name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. - Required. - :type private_endpoint_connection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the status of a private endpoint connection with the given name. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection with updated properties. Is - either a PrivateEndpointConnection type or a IO type. Required. - :type private_endpoint_connection: - ~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/__init__.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/__init__.py deleted file mode 100644 index 791d2a1bb74f..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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 ._digital_twins_operations import DigitalTwinsOperations -from ._digital_twins_endpoint_operations import DigitalTwinsEndpointOperations -from ._operations import Operations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._time_series_database_connections_operations import TimeSeriesDatabaseConnectionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DigitalTwinsOperations", - "DigitalTwinsEndpointOperations", - "Operations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "TimeSeriesDatabaseConnectionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_digital_twins_endpoint_operations.py deleted file mode 100644 index 627d029ccaa2..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_digital_twins_endpoint_operations.py +++ /dev/null @@ -1,784 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? Iterable["_models.DigitalTwinsEndpointResource"]: - """Get DigitalTwinsInstance Endpoints. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DigitalTwinsEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - """Get DigitalTwinsInstances Endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> _models.DigitalTwinsEndpointResource: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_description, (IO, bytes)): - _content = endpoint_description - else: - _json = self._serialize.body(endpoint_description, "DigitalTwinsEndpointResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: _models.DigitalTwinsEndpointResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Required. - :type endpoint_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - endpoint_name: str, - endpoint_description: Union[_models.DigitalTwinsEndpointResource, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Create or update DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :param endpoint_description: The DigitalTwinsInstance endpoint metadata and security metadata. - Is either a DigitalTwinsEndpointResource type or a IO type. Required. - :type endpoint_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - endpoint_description=endpoint_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsEndpointResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[Optional[_models.DigitalTwinsEndpointResource]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsEndpointResource]: - """Delete a DigitalTwinsInstance endpoint. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param endpoint_name: Name of Endpoint Resource. Required. - :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsEndpointResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsEndpointResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsEndpointResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_digital_twins_operations.py deleted file mode 100644 index 305aec6107af..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_digital_twins_operations.py +++ /dev/null @@ -1,1274 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=3), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DigitalTwinsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.AzureDigitalTwinsManagementClient`'s - :attr:`digital_twins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.DigitalTwinsDescription: - """Get DigitalTwinsInstances resource. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DigitalTwinsDescription or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_create, (IO, bytes)): - _content = digital_twins_create - else: - _json = self._serialize.body(digital_twins_create, "DigitalTwinsDescription") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: _models.DigitalTwinsDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Required. - :type digital_twins_create: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_create: Union[_models.DigitalTwinsDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property - is to retrieve the DigitalTwinsInstance and security metadata, and then combine them with the - modified values in a new body to update the DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_create: The DigitalTwinsInstance and security metadata. Is either a - DigitalTwinsDescription type or a IO type. Required. - :type digital_twins_create: ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_create=digital_twins_create, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> _models.DigitalTwinsDescription: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_patch_description, (IO, bytes)): - _content = digital_twins_patch_description - else: - _json = self._serialize.body(digital_twins_patch_description, "DigitalTwinsPatchDescription") - - request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: _models.DigitalTwinsPatchDescription, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsPatchDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. - Required. - :type digital_twins_patch_description: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - digital_twins_patch_description: Union[_models.DigitalTwinsPatchDescription, IO], - **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Update metadata of DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param digital_twins_patch_description: The DigitalTwinsInstance and security metadata. Is - either a DigitalTwinsPatchDescription type or a IO type. Required. - :type digital_twins_patch_description: - ~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsPatchDescription or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - digital_twins_patch_description=digital_twins_patch_description, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Optional[_models.DigitalTwinsDescription]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[Optional[_models.DigitalTwinsDescription]] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[_models.DigitalTwinsDescription]: - """Delete a DigitalTwinsInstance. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescription] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DigitalTwinsDescription", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances 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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DigitalTwinsDescription"]: - """Get all the DigitalTwinsInstances in a resource group. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :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 DigitalTwinsDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.DigitalTwinsDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.DigitalTwinsDescriptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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("DigitalTwinsDescriptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/digitalTwinsInstances" - } - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: _models.CheckNameRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - location: str, - digital_twins_instance_check_name: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. - Required. - :type digital_twins_instance_check_name: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, digital_twins_instance_check_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> _models.CheckNameResult: - """Check if a DigitalTwinsInstance name is available. - - :param location: Location of DigitalTwinsInstance. Required. - :type location: str - :param digital_twins_instance_check_name: Set the name parameter in the - DigitalTwinsInstanceCheckName structure to the name of the DigitalTwinsInstance to check. Is - either a CheckNameRequest type or a IO type. Required. - :type digital_twins_instance_check_name: - ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.CheckNameResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(digital_twins_instance_check_name, (IO, bytes)): - _content = digital_twins_instance_check_name - else: - _json = self._serialize.body(digital_twins_instance_check_name, "CheckNameRequest") - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_operations.py deleted file mode 100644 index 2e1285d3b537..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DigitalTwins/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.digitaltwins.v2023_01_31.AzureDigitalTwinsManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available DigitalTwins service 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 Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.digitaltwins.v2023_01_31.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, 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.DigitalTwins/operations"} diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_patch.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_private_link_resources_operations.py deleted file mode 100644 index f500ea706c72..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,269 +0,0 @@ -# pylint: disable=too-many-lines -# 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 sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -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.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -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( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^(?!-)[A-Za-z0-9-]{3,63}(? _models.GroupIdInformationResponse: - """List private link resources for given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformationResponse or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.GroupIdInformationResponse] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" - } - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, resource_id: str, **kwargs: Any - ) -> _models.GroupIdInformation: - """Get the specified private link resource for the given Digital Twin. - - :param resource_group_name: The name of the resource group that contains the - DigitalTwinsInstance. Required. - :type resource_group_name: str - :param resource_name: The name of the DigitalTwinsInstance. Required. - :type resource_name: str - :param resource_id: The name of the private link resource. Required. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.digitaltwins.v2023_01_31.models.GroupIdInformation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2023-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - resource_id=resource_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GroupIdInformation", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" - } diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/py.typed b/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/v2023_01_31/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/dev_requirements.txt b/sdk/digitaltwins/azure-mgmt-digitaltwins/dev_requirements.txt index efbdd0078d06..d41dee488b56 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/dev_requirements.txt +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/dev_requirements.txt @@ -1,3 +1,5 @@ -e ../../../tools/azure-sdk-tools -e ../../identity/azure-identity -e ../../resources/azure-mgmt-msi +-e ../../resources/azure-mgmt-resource +aiohttp diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_check_name_availability_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_check_name_availability_example.py index f868920279e3..177935fb9841 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_check_name_availability_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_check_name_availability_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_example.py index b2ec93ab721d..bc76d1a9a392 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_with_identity_example.py index ad4409dc1892..75acc37f2356 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_delete_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_example.py index 8617113f28a7..ab5a70aac44f 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_with_identity_example.py index 3a4ee04f99c3..4cd6ea9642ca 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_delete_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_example.py index 742a11f0f667..37c58385d9c8 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_with_identity_example.py index 99adb81dcc80..5d8ea0904a80 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_get_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_example.py index a28b89b03baf..f8bdc0d85d9b 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_identity_example.py index 39ac543a9c9e..af776f42cfa0 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_user_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_user_identity_example.py index 03cfb0967c48..9ef8ee754e84 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_user_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoint_put_with_user_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_example.py index e8ff6b8d37e5..89b2f8304598 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_with_identity_example.py index 361fc827c29f..40af1dc72cbe 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_endpoints_get_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_example.py index ea7756e72fef..3db69d2fbeb9 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_identity_example.py index 4c85ff64182d..fb152cd399b4 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_private_endpoint_connection_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_private_endpoint_connection_example.py index 6786127ca330..963474b2da0d 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_private_endpoint_connection_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_get_with_private_endpoint_connection_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_by_resource_group_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_by_resource_group_example.py index b0bcf5c04bb8..19e4e25442bc 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_by_resource_group_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_by_resource_group_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_example.py index 221db3184af3..508f3156232d 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_list_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_operations_list_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_operations_list_example.py index 36fb8842d361..6bafa861f3cc 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_operations_list_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_operations_list_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_example.py index 912c9cac54a4..62555c8b9a64 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_identity_example.py index a3db34397ddd..c241359c1707 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_public_network_access.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_public_network_access.py index b3e167696a42..43de43c39262 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_public_network_access.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_patch_with_public_network_access.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_example.py index db9a7e1c1b8e..19931e2071ed 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_identity_example.py index 83b8bc3f2127..3291b64bab70 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_public_network_access.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_public_network_access.py index f83ed93ccc50..3cca6115d1d9 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_public_network_access.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/digital_twins_put_with_public_network_access.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_by_connection_name_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_by_connection_name_example.py index 124e9c4fead1..4b30ba915b73 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_by_connection_name_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_by_connection_name_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_delete_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_delete_example.py index 97a8a7c8fe26..e6fd8712f8e2 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_delete_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_delete_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="50016170-c839-41ba-a724-51e9df440b9e", ) - response = client.private_endpoint_connections.begin_delete( + client.private_endpoint_connections.begin_delete( resource_group_name="resRg", resource_name="myDigitalTwinsService", private_endpoint_connection_name="myPrivateConnection", ).result() - print(response) # x-ms-original-file: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionDelete_example.json diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_put_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_put_example.py index df0add9fedb7..1ca141356cd0 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_put_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connection_put_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connections_list_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connections_list_example.py index 53fb72954ec2..57ca0e624faa 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connections_list_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_endpoint_connections_list_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_by_group_id_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_by_group_id_example.py index 58bcceff00d2..e4a7faed4223 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_by_group_id_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_by_group_id_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_list_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_list_example.py index 28332a99043c..947008ea8435 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_list_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/private_link_resources_list_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_delete_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_delete_example.py index 0522ab34fe62..d310863f1f4d 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_delete_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_delete_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_get_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_get_example.py index 41a23d914a0c..1d78ff15da40 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_get_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_get_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_list_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_list_example.py index 3d4e1fe1425a..fce272c7e380 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_list_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_list_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_example.py index b0dc6d9870e0..94935acac023 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_with_user_identity_example.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_with_user_identity_example.py index 673e43f9687b..b06374ea4fa3 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_with_user_identity_example.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_samples/time_series_database_connections_put_with_user_identity_example.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient """ diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/conftest.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/conftest.py new file mode 100644 index 000000000000..c2f81dd5a648 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/conftest.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + azuredigitaltwinsmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + azuredigitaltwinsmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + azuredigitaltwinsmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + azuredigitaltwinsmanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_endpoint_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_endpoint_operations.py new file mode 100644 index 000000000000..2c82033168c2 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_endpoint_operations.py @@ -0,0 +1,84 @@ +# 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 pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementDigitalTwinsEndpointOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.digital_twins_endpoint.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.digital_twins_endpoint.get( + resource_group_name=resource_group.name, + resource_name="str", + endpoint_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.digital_twins_endpoint.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + endpoint_name="str", + endpoint_description={ + "properties": "digital_twins_endpoint_resource_properties", + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.digital_twins_endpoint.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + endpoint_name="str", + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_endpoint_operations_async.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_endpoint_operations_async.py new file mode 100644 index 000000000000..8dab6aefdb2b --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_endpoint_operations_async.py @@ -0,0 +1,89 @@ +# 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 pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementDigitalTwinsEndpointOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.digital_twins_endpoint.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.digital_twins_endpoint.get( + resource_group_name=resource_group.name, + resource_name="str", + endpoint_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.digital_twins_endpoint.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + endpoint_name="str", + endpoint_description={ + "properties": "digital_twins_endpoint_resource_properties", + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.digital_twins_endpoint.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + endpoint_name="str", + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_operations.py new file mode 100644 index 000000000000..00366665a89f --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_operations.py @@ -0,0 +1,161 @@ +# 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 pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementDigitalTwinsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.digital_twins.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.digital_twins.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + digital_twins_create={ + "location": "str", + "createdTime": "2020-02-20 00:00:00", + "hostName": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "lastUpdatedTime": "2020-02-20 00:00:00", + "name": "str", + "privateEndpointConnections": [ + { + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.digital_twins.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + digital_twins_patch_description={ + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": {"publicNetworkAccess": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.digital_twins.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.digital_twins.list( + api_version="2023-01-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.digital_twins.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-01-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.digital_twins.check_name_availability( + location="str", + digital_twins_instance_check_name={"name": "str", "type": "Microsoft.DigitalTwins/digitalTwinsInstances"}, + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_operations_async.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_operations_async.py new file mode 100644 index 000000000000..0c8ea76727e1 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_digital_twins_operations_async.py @@ -0,0 +1,168 @@ +# 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 pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementDigitalTwinsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.digital_twins.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.digital_twins.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + digital_twins_create={ + "location": "str", + "createdTime": "2020-02-20 00:00:00", + "hostName": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "lastUpdatedTime": "2020-02-20 00:00:00", + "name": "str", + "privateEndpointConnections": [ + { + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.digital_twins.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + digital_twins_patch_description={ + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": {"publicNetworkAccess": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.digital_twins.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.digital_twins.list( + api_version="2023-01-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.digital_twins.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-01-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.digital_twins.check_name_availability( + location="str", + digital_twins_instance_check_name={"name": "str", "type": "Microsoft.DigitalTwins/digitalTwinsInstances"}, + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_operations.py new file mode 100644 index 000000000000..0d709b611381 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2023-01-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_operations_async.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_operations_async.py new file mode 100644 index 000000000000..62d03af8a944 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_operations_async.py @@ -0,0 +1,30 @@ +# 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 pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2023-01-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_endpoint_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..0ee1aabe455f --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_endpoint_connections_operations.py @@ -0,0 +1,93 @@ +# 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 pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_endpoint_connections_operations_async.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..62d0d0e76585 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,98 @@ +# 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 pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_link_resources_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_link_resources_operations.py new file mode 100644 index 000000000000..ad52c41f6a86 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + resource_name="str", + resource_id="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_link_resources_operations_async.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..21a79ab3fc2f --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + resource_name="str", + resource_id="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_time_series_database_connections_operations.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_time_series_database_connections_operations.py new file mode 100644 index 000000000000..754e46924d15 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_time_series_database_connections_operations.py @@ -0,0 +1,84 @@ +# 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 pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementTimeSeriesDatabaseConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.time_series_database_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.time_series_database_connections.get( + resource_group_name=resource_group.name, + resource_name="str", + time_series_database_connection_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.time_series_database_connections.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + time_series_database_connection_name="str", + time_series_database_connection_description={ + "id": "str", + "name": "str", + "properties": "time_series_database_connection_properties", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.time_series_database_connections.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + time_series_database_connection_name="str", + api_version="2023-01-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_time_series_database_connections_operations_async.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_time_series_database_connections_operations_async.py new file mode 100644 index 000000000000..afd55f94bf56 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/generated_tests/test_azure_digital_twins_management_time_series_database_connections_operations_async.py @@ -0,0 +1,89 @@ +# 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 pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureDigitalTwinsManagementTimeSeriesDatabaseConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.time_series_database_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-01-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.time_series_database_connections.get( + resource_group_name=resource_group.name, + resource_name="str", + time_series_database_connection_name="str", + api_version="2023-01-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.time_series_database_connections.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + time_series_database_connection_name="str", + time_series_database_connection_description={ + "id": "str", + "name": "str", + "properties": "time_series_database_connection_properties", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.time_series_database_connections.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + time_series_database_connection_name="str", + api_version="2023-01-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/sdk_packaging.toml b/sdk/digitaltwins/azure-mgmt-digitaltwins/sdk_packaging.toml index a6c97941c226..82d63756365d 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/sdk_packaging.toml +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/sdk_packaging.toml @@ -3,6 +3,6 @@ package_name = "azure-mgmt-digitaltwins" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Digital Twins Management" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true title = "AzureDigitalTwinsManagementClient" diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/setup.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/setup.py index af16c353497b..1d9b102f80cb 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/setup.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/setup.py @@ -1,10 +1,10 @@ #!/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 @@ -16,64 +16,70 @@ PACKAGE_PPRINT_NAME = "Digital Twins Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +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) +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') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +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', + 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.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "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', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", ) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/conftest.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/conftest.py index 6ab86de70dae..c2f81dd5a648 100644 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/conftest.py +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/conftest.py @@ -1,59 +1,47 @@ +# 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. -# +# 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 os -import platform import pytest -import sys - from dotenv import load_dotenv - -from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers -from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer - -# Ignore async tests for Python < 3.5 -collect_ignore_glob = [] -if sys.version_info < (3, 5) or platform.python_implementation() == "PyPy": - collect_ignore_glob.append("*_async.py") +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) load_dotenv() + +# aovid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000") + azuredigitaltwinsmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + azuredigitaltwinsmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + azuredigitaltwinsmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + azuredigitaltwinsmanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=azuredigitaltwinsmanagement_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") add_header_regex_sanitizer(key="Cookie", value="cookie;") add_body_key_sanitizer(json_path="$..access_token", value="access_token") - - # Remove the following sanitizers since certain fields are needed in tests and are non-sensitive: - # - AZSDK3493: $..name - remove_batch_sanitizers(["AZSDK3493"]) diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_digital_twins_operations_async_test.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_digital_twins_operations_async_test.py new file mode 100644 index 000000000000..1ddb497e123b --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_digital_twins_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestAzureDigitalTwinsManagementDigitalTwinsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.digital_twins.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.digital_twins.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_digital_twins_operations_test.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_digital_twins_operations_test.py new file mode 100644 index 000000000000..dbaf914228da --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_digital_twins_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestAzureDigitalTwinsManagementDigitalTwinsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.digital_twins.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.digital_twins.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_operations_async_test.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_operations_async_test.py new file mode 100644 index 000000000000..f66df19d3c83 --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.digitaltwins.aio import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestAzureDigitalTwinsManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list() + result = [r async for r in response] + assert result diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_operations_test.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_operations_test.py new file mode 100644 index 000000000000..2eeebc5e4d4c --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_digital_twins_management_operations_test.py @@ -0,0 +1,26 @@ +# 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 pytest +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestAzureDigitalTwinsManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list() + result = [r for r in response] + assert result diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_mgmt_digitaltwins.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_mgmt_digitaltwins.py deleted file mode 100644 index 74de6497272a..000000000000 --- a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_mgmt_digitaltwins.py +++ /dev/null @@ -1,135 +0,0 @@ -# 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. -#-------------------------------------------------------------------------- -from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient -from azure.mgmt.msi import ManagedServiceIdentityClient -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, ResourceGroupPreparer, recorded_by_proxy - -import functools -import pytest -import unittest -import random -import string - -AZURE_LOCATION = 'westus2' - -class TestDigitalTwin(AzureMgmtRecordedTestCase): - - def setup_method(self, method): - self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) - self.msi_client = self.create_mgmt_client(ManagedServiceIdentityClient) - - @recorded_by_proxy - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - def test_create_digital_twin_with_identity(self, resource_group): - SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") - RESOURCE_GROUP_NAME = resource_group.name - RESOURCE_NAME = self.get_resource_name("digitalTwin") - - # Setup Digital Twin - self.create_digital_twins_and_validate(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME) - - # Cleanup - self.client.digital_twins.begin_delete(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME).result() - - @recorded_by_proxy - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - def test_create_endpoint_with_identity(self, resource_group): - SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") - RESOURCE_GROUP_NAME = resource_group.name - RESOURCE_NAME = self.get_resource_name("digitalTwin") - - # Setup Digital Twin - msi_id = self.create_digital_twins_and_validate(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME) - - # Create endpoint - ENDPOINT_NAME = self.get_resource_name("endpoint") - ENDPOINT_BODY = { - "properties": { - "endpointType": "ServiceBus", - "authenticationType": "IdentityBased", - "endpointUri": "sb://mysb.servicebus.windows.net/", - "entityPath": "abcabc", - "identity": { - "type": "UserAssigned", - "userAssignedIdentity": msi_id - } - } - } - - result = self.client.digital_twins_endpoint.begin_create_or_update(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME, endpoint_name = ENDPOINT_NAME, endpoint_description = ENDPOINT_BODY) - result = result.result() - assert result.name == ENDPOINT_NAME - assert result.properties.identity is not None - - # Cleanup - self.client.digital_twins_endpoint.begin_delete(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME, endpoint_name = ENDPOINT_NAME).result() - self.client.digital_twins.begin_delete(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME).result() - - @recorded_by_proxy - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - def test_create_tsdbconnection_with_identity(self, resource_group): - SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") - RESOURCE_GROUP_NAME = resource_group.name - RESOURCE_NAME = self.get_resource_name("digitalTwin") - - # Setup Digital Twin - msi_id = self.create_digital_twins_and_validate(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME) - - # Create TSDB connection - TSDB_CONNECTION_NAME = self.get_resource_name("tsdbConnection") - TSDB_CONNECTION_BODY = { - "properties": { - "connectionType":"AzureDataExplorer", - "adxEndpointUri":"https://testclusterZikfikxz.eastus.kusto.windows.net", - "adxDatabaseName":"myDatabase", - "eventHubEndpointUri":"sb://mysb.servicebus.windows.net/", - "eventHubEntityPath":"abcabc", - "adxResourceId":"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.Kusto/clusters/testclusterZikfikxz", - "eventHubNamespaceResourceId":"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.EventHub/namespaces/myEH", - "identity": { - "type": "UserAssigned", - "userAssignedIdentity": msi_id - } - } - } - - # Setting polling to false since payload contains fake data - result = self.client.time_series_database_connections.begin_create_or_update(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME, time_series_database_connection_name = TSDB_CONNECTION_NAME, time_series_database_connection_description = TSDB_CONNECTION_BODY, polling = False) - result = result.result() - assert result.name == TSDB_CONNECTION_NAME - assert result.properties.identity is not None - - # Cleanup - self.client.time_series_database_connections.begin_delete(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME, time_series_database_connection_name = TSDB_CONNECTION_NAME).result() - self.client.digital_twins.begin_delete(resource_group_name = RESOURCE_GROUP_NAME, resource_name = RESOURCE_NAME).result() - - def create_digital_twins_and_validate(self, resource_group_name, resource_name): - # Setup User Assigned Identity - identity_name = self.get_resource_name("identityResource") - if self.is_live: - msi = self.msi_client.user_assigned_identities.create_or_update(resource_group_name, identity_name, {"location": AZURE_LOCATION}) - msi_id = msi.id - else: - msi_id = f"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgname/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identity_name}" - - # Create digital twin with UserAssigned - BODY = { - "location": AZURE_LOCATION, - "identity": { - "type": "UserAssigned", - "userAssignedIdentities": { - msi_id: {} - } - } - } - result = self.client.digital_twins.begin_create_or_update(resource_group_name = resource_group_name, resource_name = resource_name, digital_twins_create = BODY) - result = result.result() - assert result.name == resource_name - assert result.identity is not None - - return msi_id \ No newline at end of file diff --git a/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_mgmt_digitaltwins_test.py b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_mgmt_digitaltwins_test.py new file mode 100644 index 000000000000..61d03764f52d --- /dev/null +++ b/sdk/digitaltwins/azure-mgmt-digitaltwins/tests/test_azure_mgmt_digitaltwins_test.py @@ -0,0 +1,165 @@ +# 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. +# -------------------------------------------------------------------------- +from azure.mgmt.digitaltwins import AzureDigitalTwinsManagementClient +from azure.mgmt.msi import ManagedServiceIdentityClient +from devtools_testutils import ( + AzureMgmtRecordedTestCase, + RandomNameResourceGroupPreparer, + ResourceGroupPreparer, + recorded_by_proxy, +) + +import functools +import pytest +import unittest +import random +import string + +AZURE_LOCATION = "westus2" + + +@pytest.mark.live_test_only +class TestDigitalTwin(AzureMgmtRecordedTestCase): + + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureDigitalTwinsManagementClient) + self.msi_client = self.create_mgmt_client(ManagedServiceIdentityClient) + + @recorded_by_proxy + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + def test_create_digital_twin_with_identity(self, resource_group): + SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") + RESOURCE_GROUP_NAME = resource_group.name + RESOURCE_NAME = self.get_resource_name("digitalTwin") + + # Setup Digital Twin + self.create_digital_twins_and_validate(resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME) + + # Cleanup + self.client.digital_twins.begin_delete( + resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME + ).result() + + @recorded_by_proxy + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + def test_create_endpoint_with_identity(self, resource_group): + SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") + RESOURCE_GROUP_NAME = resource_group.name + RESOURCE_NAME = self.get_resource_name("digitalTwin") + + # Setup Digital Twin + msi_id = self.create_digital_twins_and_validate( + resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME + ) + + # Create endpoint + ENDPOINT_NAME = self.get_resource_name("endpoint") + ENDPOINT_BODY = { + "properties": { + "endpointType": "ServiceBus", + "authenticationType": "IdentityBased", + "endpointUri": "sb://mysb.servicebus.windows.net/", + "entityPath": "abcabc", + "identity": {"type": "UserAssigned", "userAssignedIdentity": msi_id}, + } + } + + result = self.client.digital_twins_endpoint.begin_create_or_update( + resource_group_name=RESOURCE_GROUP_NAME, + resource_name=RESOURCE_NAME, + endpoint_name=ENDPOINT_NAME, + endpoint_description=ENDPOINT_BODY, + ) + result = result.result() + assert result.name == ENDPOINT_NAME + assert result.properties.identity is not None + + # Cleanup + self.client.digital_twins_endpoint.begin_delete( + resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME, endpoint_name=ENDPOINT_NAME + ).result() + self.client.digital_twins.begin_delete( + resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME + ).result() + + @recorded_by_proxy + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + def test_create_tsdbconnection_with_identity(self, resource_group): + SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") + RESOURCE_GROUP_NAME = resource_group.name + RESOURCE_NAME = self.get_resource_name("digitalTwin") + + # Setup Digital Twin + msi_id = self.create_digital_twins_and_validate( + resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME + ) + + # Create TSDB connection + TSDB_CONNECTION_NAME = self.get_resource_name("tsdbConnection") + TSDB_CONNECTION_BODY = { + "properties": { + "connectionType": "AzureDataExplorer", + "adxEndpointUri": f"https://{RESOURCE_NAME}.eastus.kusto.windows.net", + "adxDatabaseName": "myDatabase", + "eventHubEndpointUri": "sb://mysb.servicebus.windows.net/", + "eventHubEntityPath": "abcabc", + "adxResourceId": f"/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.Kusto/clusters/{RESOURCE_NAME}", + "eventHubNamespaceResourceId": f"/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.EventHub/namespaces/myEH", + "identity": {"type": "UserAssigned", "userAssignedIdentity": msi_id}, + } + } + + # Setting polling to false since payload contains fake data + result = self.client.time_series_database_connections.begin_create_or_update( + resource_group_name=RESOURCE_GROUP_NAME, + resource_name=RESOURCE_NAME, + time_series_database_connection_name=TSDB_CONNECTION_NAME, + time_series_database_connection_description=TSDB_CONNECTION_BODY, + polling=False, + ) + result = result.result() + assert result.name == TSDB_CONNECTION_NAME + assert result.properties.identity is not None + + # Cleanup + self.client.time_series_database_connections.begin_delete( + resource_group_name=RESOURCE_GROUP_NAME, + resource_name=RESOURCE_NAME, + time_series_database_connection_name=TSDB_CONNECTION_NAME, + ).result() + self.client.digital_twins.begin_delete( + resource_group_name=RESOURCE_GROUP_NAME, resource_name=RESOURCE_NAME + ).result() + + def create_digital_twins_and_validate(self, resource_group_name, resource_name): + SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") + RESOURCE_GROUP_NAME = resource_group_name + + # Setup User Assigned Identity + identity_name = self.get_resource_name("identityResource") + if self.is_live: + msi = self.msi_client.user_assigned_identities.create_or_update( + resource_group_name, identity_name, {"location": AZURE_LOCATION} + ) + msi_id = msi.id + else: + msi_id = f"/subscriptions/{SUBSCRIPTION_ID}/resourcegroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identity_name}" + + # Create digital twin with UserAssigned + BODY = { + "location": AZURE_LOCATION, + "identity": {"type": "UserAssigned", "userAssignedIdentities": {msi_id: {}}}, + } + result = self.client.digital_twins.begin_create_or_update( + resource_group_name=resource_group_name, resource_name=resource_name, digital_twins_create=BODY + ) + result = result.result() + assert result.name == resource_name + assert result.identity is not None + + return msi_id