From cdfe879765e6c0c61e5d990b5fa50aee5f47b365 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 27 Sep 2021 03:09:45 +0000 Subject: [PATCH] CodeGen from PR 16146 in Azure/azure-rest-api-specs [Hub Generated] Microsoft.ServiceLinker API version 2021-11-01-preview (#16146) * ServiceLinker RP version 2021-11-01-preview * Update readme.md * Update readme.python.md * Update readme.md * fix lintrule error * fix format * add multiapi section to readme.go.md Co-authored-by: Nan Jiang Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../azure-mgmt-servicelinker/CHANGELOG.md | 5 + .../azure-mgmt-servicelinker/MANIFEST.in | 6 + .../azure-mgmt-servicelinker/README.md | 27 + .../azure-mgmt-servicelinker/_meta.json | 11 + .../azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/servicelinker/__init__.py | 19 + .../mgmt/servicelinker/_configuration.py | 65 ++ .../azure/mgmt/servicelinker/_metadata.json | 92 ++ .../_microsoft_service_linker.py | 88 ++ .../azure/mgmt/servicelinker/_version.py | 9 + .../azure/mgmt/servicelinker/aio/__init__.py | 10 + .../mgmt/servicelinker/aio/_configuration.py | 61 ++ .../aio/_microsoft_service_linker.py | 81 ++ .../servicelinker/aio/operations/__init__.py | 15 + .../aio/operations/_linker_operations.py | 713 +++++++++++++++ .../aio/operations/_operations.py | 105 +++ .../mgmt/servicelinker/models/__init__.py | 91 ++ .../models/_microsoft_service_linker_enums.py | 83 ++ .../mgmt/servicelinker/models/_models.py | 761 ++++++++++++++++ .../mgmt/servicelinker/models/_models_py3.py | 815 ++++++++++++++++++ .../mgmt/servicelinker/operations/__init__.py | 15 + .../operations/_linker_operations.py | 728 ++++++++++++++++ .../servicelinker/operations/_operations.py | 110 +++ .../azure/mgmt/servicelinker/py.typed | 1 + .../sdk_packaging.toml | 9 + .../azure-mgmt-servicelinker/setup.cfg | 2 + .../azure-mgmt-servicelinker/setup.py | 90 ++ sdk/servicelinker/ci.yml | 33 + 29 files changed, 4047 insertions(+) create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/MANIFEST.in create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/README.md create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/_meta.json create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_metadata.json create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_microsoft_service_linker.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_microsoft_service_linker.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_microsoft_service_linker_enums.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/__init__.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/py.typed create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/sdk_packaging.toml create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/setup.cfg create mode 100644 sdk/servicelinker/azure-mgmt-servicelinker/setup.py create mode 100644 sdk/servicelinker/ci.yml diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md b/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/MANIFEST.in b/sdk/servicelinker/azure-mgmt-servicelinker/MANIFEST.in new file mode 100644 index 000000000000..3a9b6517412b --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/README.md b/sdk/servicelinker/azure-mgmt-servicelinker/README.md new file mode 100644 index 000000000000..7d5290661527 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-servicelinker%2FREADME.png) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json b/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json new file mode 100644 index 000000000000..9d2bd1e3bc74 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.5", + "use": [ + "@autorest/python@5.8.4", + "@autorest/modelerfour@4.19.2" + ], + "commit": "70c107255ecd734617cab71f514401151eadb1e9", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/servicelinker/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "readme": "specification/servicelinker/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/__init__.py new file mode 100644 index 000000000000..dd9846735965 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_service_linker import MicrosoftServiceLinker +from ._version import VERSION + +__version__ = VERSION +__all__ = ['MicrosoftServiceLinker'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py new file mode 100644 index 000000000000..ab3e7eccff20 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class MicrosoftServiceLinkerConfiguration(Configuration): + """Configuration for MicrosoftServiceLinker. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ + + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(MicrosoftServiceLinkerConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.api_version = "2021-11-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-servicelinker/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_metadata.json b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_metadata.json new file mode 100644 index 000000000000..47506e4ec7a5 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_metadata.json @@ -0,0 +1,92 @@ +{ + "chosen_version": "2021-11-01-preview", + "total_api_version_list": ["2021-11-01-preview"], + "client": { + "name": "MicrosoftServiceLinker", + "filename": "_microsoft_service_linker", + "description": "Microsoft.ServiceLinker provider.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftServiceLinkerConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftServiceLinkerConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "linker": "LinkerOperations", + "operations": "Operations" + } +} \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_microsoft_service_linker.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_microsoft_service_linker.py new file mode 100644 index 000000000000..d7b0dc4021a7 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_microsoft_service_linker.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import MicrosoftServiceLinkerConfiguration +from .operations import LinkerOperations +from .operations import Operations +from . import models + + +class MicrosoftServiceLinker(object): + """Microsoft.ServiceLinker provider. + + :ivar linker: LinkerOperations operations + :vartype linker: microsoft_service_linker.operations.LinkerOperations + :ivar operations: Operations operations + :vartype operations: microsoft_service_linker.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftServiceLinkerConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.linker = LinkerOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> MicrosoftServiceLinker + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/__init__.py new file mode 100644 index 000000000000..774d140f5a52 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_service_linker import MicrosoftServiceLinker +__all__ = ['MicrosoftServiceLinker'] diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py new file mode 100644 index 000000000000..1baecd99d20b --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MicrosoftServiceLinkerConfiguration(Configuration): + """Configuration for MicrosoftServiceLinker. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(MicrosoftServiceLinkerConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.api_version = "2021-11-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-servicelinker/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_microsoft_service_linker.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_microsoft_service_linker.py new file mode 100644 index 000000000000..d6de8b6375f9 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_microsoft_service_linker.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import MicrosoftServiceLinkerConfiguration +from .operations import LinkerOperations +from .operations import Operations +from .. import models + + +class MicrosoftServiceLinker(object): + """Microsoft.ServiceLinker provider. + + :ivar linker: LinkerOperations operations + :vartype linker: microsoft_service_linker.aio.operations.LinkerOperations + :ivar operations: Operations operations + :vartype operations: microsoft_service_linker.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftServiceLinkerConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.linker = LinkerOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MicrosoftServiceLinker": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/__init__.py new file mode 100644 index 000000000000..a4070d52b65e --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._linker_operations import LinkerOperations +from ._operations import Operations + +__all__ = [ + 'LinkerOperations', + 'Operations', +] diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py new file mode 100644 index 000000000000..514ee5a3e94d --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py @@ -0,0 +1,713 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LinkerOperations: + """LinkerOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_service_linker.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_uri: str, + **kwargs: Any + ) -> AsyncIterable["_models.LinkerList"]: + """Returns list of Linkers which connects to the resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LinkerList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_service_linker.models.LinkerList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LinkerList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers'} # type: ignore + + async def get( + self, + resource_uri: str, + linker_name: str, + **kwargs: Any + ) -> "_models.LinkerResource": + """Returns Linker resource for a given name. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LinkerResource, or the result of cls(response) + :rtype: ~microsoft_service_linker.models.LinkerResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_uri: str, + linker_name: str, + parameters: "_models.LinkerResource", + **kwargs: Any + ) -> "_models.LinkerResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LinkerResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_uri: str, + linker_name: str, + parameters: "_models.LinkerResource", + **kwargs: Any + ) -> AsyncLROPoller["_models.LinkerResource"]: + """Create or update linker resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :param parameters: Linker details. + :type parameters: ~microsoft_service_linker.models.LinkerResource + :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 LinkerResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_service_linker.models.LinkerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_uri=resource_uri, + linker_name=linker_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def _delete_initial( + self, + resource_uri: str, + linker_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def begin_delete( + self, + resource_uri: str, + linker_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a link. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_uri=resource_uri, + linker_name=linker_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def _update_initial( + self, + resource_uri: str, + linker_name: str, + parameters: "_models.LinkerPatch", + **kwargs: Any + ) -> "_models.LinkerResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LinkerPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def begin_update( + self, + resource_uri: str, + linker_name: str, + parameters: "_models.LinkerPatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.LinkerResource"]: + """Operation to update an existing link. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :param parameters: Linker details. + :type parameters: ~microsoft_service_linker.models.LinkerPatch + :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 LinkerResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_service_linker.models.LinkerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_uri=resource_uri, + linker_name=linker_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + async def _validate_initial( + self, + resource_uri: str, + linker_name: str, + **kwargs: Any + ) -> Optional["_models.ValidateResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self._validate_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker'} # type: ignore + + async def begin_validate( + self, + resource_uri: str, + linker_name: str, + **kwargs: Any + ) -> AsyncLROPoller["_models.ValidateResult"]: + """Validate a link. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_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 ValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_service_linker.models.ValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_initial( + resource_uri=resource_uri, + linker_name=linker_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker'} # type: ignore + + async def list_configurations( + self, + resource_uri: str, + linker_name: str, + **kwargs: Any + ) -> "_models.SourceConfigurationResult": + """list source configurations for a linker. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceConfigurationResult, or the result of cls(response) + :rtype: ~microsoft_service_linker.models.SourceConfigurationResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceConfigurationResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_configurations.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SourceConfigurationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_configurations.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations'} # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py new file mode 100644 index 000000000000..13a1fc23033b --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_service_linker.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists the available ServiceLinker REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_service_linker.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.ServiceLinker/operations'} # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py new file mode 100644 index 000000000000..472f19f15b21 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AuthInfoBase + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import LinkerList + from ._models_py3 import LinkerPatch + from ._models_py3 import LinkerResource + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ProxyResource + from ._models_py3 import Resource + from ._models_py3 import SecretAuthInfo + from ._models_py3 import ServicePrincipalCertificateAuthInfo + from ._models_py3 import ServicePrincipalSecretAuthInfo + from ._models_py3 import SourceConfiguration + from ._models_py3 import SourceConfigurationResult + from ._models_py3 import SystemAssignedIdentityAuthInfo + from ._models_py3 import SystemData + from ._models_py3 import UserAssignedIdentityAuthInfo + from ._models_py3 import ValidateResult +except (SyntaxError, ImportError): + from ._models import AuthInfoBase # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import LinkerList # type: ignore + from ._models import LinkerPatch # type: ignore + from ._models import LinkerResource # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore + from ._models import SecretAuthInfo # type: ignore + from ._models import ServicePrincipalCertificateAuthInfo # type: ignore + from ._models import ServicePrincipalSecretAuthInfo # type: ignore + from ._models import SourceConfiguration # type: ignore + from ._models import SourceConfigurationResult # type: ignore + from ._models import SystemAssignedIdentityAuthInfo # type: ignore + from ._models import SystemData # type: ignore + from ._models import UserAssignedIdentityAuthInfo # type: ignore + from ._models import ValidateResult # type: ignore + +from ._microsoft_service_linker_enums import ( + ActionType, + AuthType, + ClientType, + CreatedByType, + LinkerStatus, + Origin, +) + +__all__ = [ + 'AuthInfoBase', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'LinkerList', + 'LinkerPatch', + 'LinkerResource', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'SecretAuthInfo', + 'ServicePrincipalCertificateAuthInfo', + 'ServicePrincipalSecretAuthInfo', + 'SourceConfiguration', + 'SourceConfigurationResult', + 'SystemAssignedIdentityAuthInfo', + 'SystemData', + 'UserAssignedIdentityAuthInfo', + 'ValidateResult', + 'ActionType', + 'AuthType', + 'ClientType', + 'CreatedByType', + 'LinkerStatus', + 'Origin', +] diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_microsoft_service_linker_enums.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_microsoft_service_linker_enums.py new file mode 100644 index 000000000000..de5aebfafedf --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_microsoft_service_linker_enums.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class AuthType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The authentication type. + """ + + SYSTEM_ASSIGNED_IDENTITY = "systemAssignedIdentity" + USER_ASSIGNED_IDENTITY = "userAssignedIdentity" + SERVICE_PRINCIPAL_SECRET = "servicePrincipalSecret" + SERVICE_PRINCIPAL_CERTIFICATE = "servicePrincipalCertificate" + SECRET = "secret" + +class ClientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The application client type + """ + + NONE = "none" + DOTNET = "dotnet" + JAVA = "java" + PYTHON = "python" + GO = "go" + PHP = "php" + RUBY = "ruby" + DJANGO = "django" + NODEJS = "nodejs" + SPRING_BOOT = "springBoot" + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class LinkerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies if the linker is healthy. + """ + + HEALTHY = "Healthy" + NOT_HEALTHY = "Not healthy" + +class Origin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models.py new file mode 100644 index 000000000000..86ce993725b2 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models.py @@ -0,0 +1,761 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class AuthInfoBase(msrest.serialization.Model): + """The authentication info. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: SecretAuthInfo, ServicePrincipalCertificateAuthInfo, ServicePrincipalSecretAuthInfo, SystemAssignedIdentityAuthInfo, UserAssignedIdentityAuthInfo. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + """ + + _validation = { + 'auth_type': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + } + + _subtype_map = { + 'auth_type': {'secret': 'SecretAuthInfo', 'servicePrincipalCertificate': 'ServicePrincipalCertificateAuthInfo', 'servicePrincipalSecret': 'ServicePrincipalSecretAuthInfo', 'systemAssignedIdentity': 'SystemAssignedIdentityAuthInfo', 'userAssignedIdentity': 'UserAssignedIdentityAuthInfo'} + } + + def __init__( + self, + **kwargs + ): + super(AuthInfoBase, self).__init__(**kwargs) + self.auth_type = None # type: Optional[str] + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~microsoft_service_linker.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~microsoft_service_linker.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~microsoft_service_linker.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class LinkerList(msrest.serialization.Model): + """The list of Linker. + + :param next_link: The link used to get the next page of Linker list. + :type next_link: str + :param value: The list of Linkers. + :type value: list[~microsoft_service_linker.models.LinkerResource] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[LinkerResource]'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkerList, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class LinkerPatch(msrest.serialization.Model): + """A linker to be updated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param target_id: The resource Id of target service. + :type target_id: str + :param auth_info: The authentication type. + :type auth_info: ~microsoft_service_linker.models.AuthInfoBase + :param client_type: The application client type. Possible values include: "none", "dotnet", + "java", "python", "go", "php", "ruby", "django", "nodejs", "springBoot". + :type client_type: str or ~microsoft_service_linker.models.ClientType + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'target_id': {'key': 'properties.targetId', 'type': 'str'}, + 'auth_info': {'key': 'properties.authInfo', 'type': 'AuthInfoBase'}, + 'client_type': {'key': 'properties.clientType', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkerPatch, self).__init__(**kwargs) + self.target_id = kwargs.get('target_id', None) + self.auth_info = kwargs.get('auth_info', None) + self.client_type = kwargs.get('client_type', None) + self.provisioning_state = None + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + +class LinkerResource(ProxyResource): + """Linker of source and target resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system data. + :vartype system_data: ~microsoft_service_linker.models.SystemData + :param target_id: The resource Id of target service. + :type target_id: str + :param auth_info: The authentication type. + :type auth_info: ~microsoft_service_linker.models.AuthInfoBase + :param client_type: The application client type. Possible values include: "none", "dotnet", + "java", "python", "go", "php", "ruby", "django", "nodejs", "springBoot". + :type client_type: str or ~microsoft_service_linker.models.ClientType + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'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'}, + 'target_id': {'key': 'properties.targetId', 'type': 'str'}, + 'auth_info': {'key': 'properties.authInfo', 'type': 'AuthInfoBase'}, + 'client_type': {'key': 'properties.clientType', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkerResource, self).__init__(**kwargs) + self.system_data = None + self.target_id = kwargs.get('target_id', None) + self.auth_info = kwargs.get('auth_info', None) + self.client_type = kwargs.get('client_type', None) + self.provisioning_state = None + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~microsoft_service_linker.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~microsoft_service_linker.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~microsoft_service_linker.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = kwargs.get('display', None) + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~microsoft_service_linker.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SecretAuthInfo(AuthInfoBase): + """The authentication info when authType is secret. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param name: Username or account name for secret auth. + :type name: str + :param secret: Password or account key for secret auth. + :type secret: str + """ + + _validation = { + 'auth_type': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'secret': {'key': 'secret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SecretAuthInfo, self).__init__(**kwargs) + self.auth_type = 'secret' # type: str + self.name = kwargs.get('name', None) + self.secret = kwargs.get('secret', None) + + +class ServicePrincipalCertificateAuthInfo(AuthInfoBase): + """The authentication info when authType is servicePrincipal certificate. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param client_id: Required. Application clientId for servicePrincipal auth. + :type client_id: str + :param principal_id: Required. Principal Id for servicePrincipal auth. + :type principal_id: str + :param certificate: Required. ServicePrincipal certificate for servicePrincipal auth. + :type certificate: str + """ + + _validation = { + 'auth_type': {'required': True}, + 'client_id': {'required': True}, + 'principal_id': {'required': True}, + 'certificate': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'certificate': {'key': 'certificate', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServicePrincipalCertificateAuthInfo, self).__init__(**kwargs) + self.auth_type = 'servicePrincipalCertificate' # type: str + self.client_id = kwargs['client_id'] + self.principal_id = kwargs['principal_id'] + self.certificate = kwargs['certificate'] + + +class ServicePrincipalSecretAuthInfo(AuthInfoBase): + """The authentication info when authType is servicePrincipal secret. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param client_id: Required. ServicePrincipal application clientId for servicePrincipal auth. + :type client_id: str + :param principal_id: Required. Principal Id for servicePrincipal auth. + :type principal_id: str + :param secret: Required. Secret for servicePrincipal auth. + :type secret: str + """ + + _validation = { + 'auth_type': {'required': True}, + 'client_id': {'required': True}, + 'principal_id': {'required': True}, + 'secret': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'secret': {'key': 'secret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServicePrincipalSecretAuthInfo, self).__init__(**kwargs) + self.auth_type = 'servicePrincipalSecret' # type: str + self.client_id = kwargs['client_id'] + self.principal_id = kwargs['principal_id'] + self.secret = kwargs['secret'] + + +class SourceConfiguration(msrest.serialization.Model): + """A configuration item for source resource. + + :param name: The name of setting. + :type name: str + :param value: The value of setting. + :type value: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SourceConfiguration, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + + +class SourceConfigurationResult(msrest.serialization.Model): + """Configurations for source resource, include appSettings, connectionString and serviceBindings. + + :param configurations: The configuration properties for source resource. + :type configurations: list[~microsoft_service_linker.models.SourceConfiguration] + """ + + _attribute_map = { + 'configurations': {'key': 'configurations', 'type': '[SourceConfiguration]'}, + } + + def __init__( + self, + **kwargs + ): + super(SourceConfigurationResult, self).__init__(**kwargs) + self.configurations = kwargs.get('configurations', None) + + +class SystemAssignedIdentityAuthInfo(AuthInfoBase): + """The authentication info when authType is systemAssignedIdentity. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + """ + + _validation = { + 'auth_type': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemAssignedIdentityAuthInfo, self).__init__(**kwargs) + self.auth_type = 'systemAssignedIdentity' # type: str + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~microsoft_service_linker.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~microsoft_service_linker.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type 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, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + +class UserAssignedIdentityAuthInfo(AuthInfoBase): + """The authentication info when authType is userAssignedIdentity. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param client_id: Required. Client Id for userAssignedIdentity. + :type client_id: str + :param subscription_id: Required. Subscription id for userAssignedIdentity. + :type subscription_id: str + """ + + _validation = { + 'auth_type': {'required': True}, + 'client_id': {'required': True}, + 'subscription_id': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserAssignedIdentityAuthInfo, self).__init__(**kwargs) + self.auth_type = 'userAssignedIdentity' # type: str + self.client_id = kwargs['client_id'] + self.subscription_id = kwargs['subscription_id'] + + +class ValidateResult(msrest.serialization.Model): + """The validation result for a linker. + + :param name: The linker name. + :type name: str + :param linker_status: Specifies if the linker is healthy. Possible values include: "Healthy", + "Not healthy". + :type linker_status: str or ~microsoft_service_linker.models.LinkerStatus + :param reason: The reason of the error. + :type reason: str + :param report_start_time_utc: The start time of the validation report. + :type report_start_time_utc: ~datetime.datetime + :param report_end_time_utc: The end time of the validation report. + :type report_end_time_utc: ~datetime.datetime + :param target_id: The resource Id of target service. + :type target_id: str + :param auth_type: The authentication type. Possible values include: "systemAssignedIdentity", + "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'linker_status': {'key': 'linkerStatus', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'report_start_time_utc': {'key': 'reportStartTimeUtc', 'type': 'iso-8601'}, + 'report_end_time_utc': {'key': 'reportEndTimeUtc', 'type': 'iso-8601'}, + 'target_id': {'key': 'targetId', 'type': 'str'}, + 'auth_type': {'key': 'authType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ValidateResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.linker_status = kwargs.get('linker_status', None) + self.reason = kwargs.get('reason', None) + self.report_start_time_utc = kwargs.get('report_start_time_utc', None) + self.report_end_time_utc = kwargs.get('report_end_time_utc', None) + self.target_id = kwargs.get('target_id', None) + self.auth_type = kwargs.get('auth_type', None) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py new file mode 100644 index 000000000000..422f79617f46 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py @@ -0,0 +1,815 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._microsoft_service_linker_enums import * + + +class AuthInfoBase(msrest.serialization.Model): + """The authentication info. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: SecretAuthInfo, ServicePrincipalCertificateAuthInfo, ServicePrincipalSecretAuthInfo, SystemAssignedIdentityAuthInfo, UserAssignedIdentityAuthInfo. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + """ + + _validation = { + 'auth_type': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + } + + _subtype_map = { + 'auth_type': {'secret': 'SecretAuthInfo', 'servicePrincipalCertificate': 'ServicePrincipalCertificateAuthInfo', 'servicePrincipalSecret': 'ServicePrincipalSecretAuthInfo', 'systemAssignedIdentity': 'SystemAssignedIdentityAuthInfo', 'userAssignedIdentity': 'UserAssignedIdentityAuthInfo'} + } + + def __init__( + self, + **kwargs + ): + super(AuthInfoBase, self).__init__(**kwargs) + self.auth_type = None # type: Optional[str] + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~microsoft_service_linker.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~microsoft_service_linker.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~microsoft_service_linker.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class LinkerList(msrest.serialization.Model): + """The list of Linker. + + :param next_link: The link used to get the next page of Linker list. + :type next_link: str + :param value: The list of Linkers. + :type value: list[~microsoft_service_linker.models.LinkerResource] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[LinkerResource]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["LinkerResource"]] = None, + **kwargs + ): + super(LinkerList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class LinkerPatch(msrest.serialization.Model): + """A linker to be updated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param target_id: The resource Id of target service. + :type target_id: str + :param auth_info: The authentication type. + :type auth_info: ~microsoft_service_linker.models.AuthInfoBase + :param client_type: The application client type. Possible values include: "none", "dotnet", + "java", "python", "go", "php", "ruby", "django", "nodejs", "springBoot". + :type client_type: str or ~microsoft_service_linker.models.ClientType + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'target_id': {'key': 'properties.targetId', 'type': 'str'}, + 'auth_info': {'key': 'properties.authInfo', 'type': 'AuthInfoBase'}, + 'client_type': {'key': 'properties.clientType', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + target_id: Optional[str] = None, + auth_info: Optional["AuthInfoBase"] = None, + client_type: Optional[Union[str, "ClientType"]] = None, + **kwargs + ): + super(LinkerPatch, self).__init__(**kwargs) + self.target_id = target_id + self.auth_info = auth_info + self.client_type = client_type + self.provisioning_state = None + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + +class LinkerResource(ProxyResource): + """Linker of source and target resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system data. + :vartype system_data: ~microsoft_service_linker.models.SystemData + :param target_id: The resource Id of target service. + :type target_id: str + :param auth_info: The authentication type. + :type auth_info: ~microsoft_service_linker.models.AuthInfoBase + :param client_type: The application client type. Possible values include: "none", "dotnet", + "java", "python", "go", "php", "ruby", "django", "nodejs", "springBoot". + :type client_type: str or ~microsoft_service_linker.models.ClientType + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'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'}, + 'target_id': {'key': 'properties.targetId', 'type': 'str'}, + 'auth_info': {'key': 'properties.authInfo', 'type': 'AuthInfoBase'}, + 'client_type': {'key': 'properties.clientType', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + target_id: Optional[str] = None, + auth_info: Optional["AuthInfoBase"] = None, + client_type: Optional[Union[str, "ClientType"]] = None, + **kwargs + ): + super(LinkerResource, self).__init__(**kwargs) + self.system_data = None + self.target_id = target_id + self.auth_info = auth_info + self.client_type = client_type + self.provisioning_state = None + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~microsoft_service_linker.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~microsoft_service_linker.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~microsoft_service_linker.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~microsoft_service_linker.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SecretAuthInfo(AuthInfoBase): + """The authentication info when authType is secret. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param name: Username or account name for secret auth. + :type name: str + :param secret: Password or account key for secret auth. + :type secret: str + """ + + _validation = { + 'auth_type': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'secret': {'key': 'secret', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + secret: Optional[str] = None, + **kwargs + ): + super(SecretAuthInfo, self).__init__(**kwargs) + self.auth_type = 'secret' # type: str + self.name = name + self.secret = secret + + +class ServicePrincipalCertificateAuthInfo(AuthInfoBase): + """The authentication info when authType is servicePrincipal certificate. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param client_id: Required. Application clientId for servicePrincipal auth. + :type client_id: str + :param principal_id: Required. Principal Id for servicePrincipal auth. + :type principal_id: str + :param certificate: Required. ServicePrincipal certificate for servicePrincipal auth. + :type certificate: str + """ + + _validation = { + 'auth_type': {'required': True}, + 'client_id': {'required': True}, + 'principal_id': {'required': True}, + 'certificate': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'certificate': {'key': 'certificate', 'type': 'str'}, + } + + def __init__( + self, + *, + client_id: str, + principal_id: str, + certificate: str, + **kwargs + ): + super(ServicePrincipalCertificateAuthInfo, self).__init__(**kwargs) + self.auth_type = 'servicePrincipalCertificate' # type: str + self.client_id = client_id + self.principal_id = principal_id + self.certificate = certificate + + +class ServicePrincipalSecretAuthInfo(AuthInfoBase): + """The authentication info when authType is servicePrincipal secret. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param client_id: Required. ServicePrincipal application clientId for servicePrincipal auth. + :type client_id: str + :param principal_id: Required. Principal Id for servicePrincipal auth. + :type principal_id: str + :param secret: Required. Secret for servicePrincipal auth. + :type secret: str + """ + + _validation = { + 'auth_type': {'required': True}, + 'client_id': {'required': True}, + 'principal_id': {'required': True}, + 'secret': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'secret': {'key': 'secret', 'type': 'str'}, + } + + def __init__( + self, + *, + client_id: str, + principal_id: str, + secret: str, + **kwargs + ): + super(ServicePrincipalSecretAuthInfo, self).__init__(**kwargs) + self.auth_type = 'servicePrincipalSecret' # type: str + self.client_id = client_id + self.principal_id = principal_id + self.secret = secret + + +class SourceConfiguration(msrest.serialization.Model): + """A configuration item for source resource. + + :param name: The name of setting. + :type name: str + :param value: The value of setting. + :type value: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): + super(SourceConfiguration, self).__init__(**kwargs) + self.name = name + self.value = value + + +class SourceConfigurationResult(msrest.serialization.Model): + """Configurations for source resource, include appSettings, connectionString and serviceBindings. + + :param configurations: The configuration properties for source resource. + :type configurations: list[~microsoft_service_linker.models.SourceConfiguration] + """ + + _attribute_map = { + 'configurations': {'key': 'configurations', 'type': '[SourceConfiguration]'}, + } + + def __init__( + self, + *, + configurations: Optional[List["SourceConfiguration"]] = None, + **kwargs + ): + super(SourceConfigurationResult, self).__init__(**kwargs) + self.configurations = configurations + + +class SystemAssignedIdentityAuthInfo(AuthInfoBase): + """The authentication info when authType is systemAssignedIdentity. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + """ + + _validation = { + 'auth_type': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemAssignedIdentityAuthInfo, self).__init__(**kwargs) + self.auth_type = 'systemAssignedIdentity' # type: str + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~microsoft_service_linker.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~microsoft_service_linker.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type 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, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__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 UserAssignedIdentityAuthInfo(AuthInfoBase): + """The authentication info when authType is userAssignedIdentity. + + All required parameters must be populated in order to send to Azure. + + :param auth_type: Required. The authentication type.Constant filled by server. Possible values + include: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", + "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + :param client_id: Required. Client Id for userAssignedIdentity. + :type client_id: str + :param subscription_id: Required. Subscription id for userAssignedIdentity. + :type subscription_id: str + """ + + _validation = { + 'auth_type': {'required': True}, + 'client_id': {'required': True}, + 'subscription_id': {'required': True}, + } + + _attribute_map = { + 'auth_type': {'key': 'authType', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + *, + client_id: str, + subscription_id: str, + **kwargs + ): + super(UserAssignedIdentityAuthInfo, self).__init__(**kwargs) + self.auth_type = 'userAssignedIdentity' # type: str + self.client_id = client_id + self.subscription_id = subscription_id + + +class ValidateResult(msrest.serialization.Model): + """The validation result for a linker. + + :param name: The linker name. + :type name: str + :param linker_status: Specifies if the linker is healthy. Possible values include: "Healthy", + "Not healthy". + :type linker_status: str or ~microsoft_service_linker.models.LinkerStatus + :param reason: The reason of the error. + :type reason: str + :param report_start_time_utc: The start time of the validation report. + :type report_start_time_utc: ~datetime.datetime + :param report_end_time_utc: The end time of the validation report. + :type report_end_time_utc: ~datetime.datetime + :param target_id: The resource Id of target service. + :type target_id: str + :param auth_type: The authentication type. Possible values include: "systemAssignedIdentity", + "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret". + :type auth_type: str or ~microsoft_service_linker.models.AuthType + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'linker_status': {'key': 'linkerStatus', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'report_start_time_utc': {'key': 'reportStartTimeUtc', 'type': 'iso-8601'}, + 'report_end_time_utc': {'key': 'reportEndTimeUtc', 'type': 'iso-8601'}, + 'target_id': {'key': 'targetId', 'type': 'str'}, + 'auth_type': {'key': 'authType', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + linker_status: Optional[Union[str, "LinkerStatus"]] = None, + reason: Optional[str] = None, + report_start_time_utc: Optional[datetime.datetime] = None, + report_end_time_utc: Optional[datetime.datetime] = None, + target_id: Optional[str] = None, + auth_type: Optional[Union[str, "AuthType"]] = None, + **kwargs + ): + super(ValidateResult, self).__init__(**kwargs) + self.name = name + self.linker_status = linker_status + self.reason = reason + self.report_start_time_utc = report_start_time_utc + self.report_end_time_utc = report_end_time_utc + self.target_id = target_id + self.auth_type = auth_type diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/__init__.py new file mode 100644 index 000000000000..a4070d52b65e --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._linker_operations import LinkerOperations +from ._operations import Operations + +__all__ = [ + 'LinkerOperations', + 'Operations', +] diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py new file mode 100644 index 000000000000..b1ae62320f74 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py @@ -0,0 +1,728 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class LinkerOperations(object): + """LinkerOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_service_linker.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_uri, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LinkerList"] + """Returns list of Linkers which connects to the resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LinkerList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_service_linker.models.LinkerList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LinkerList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers'} # type: ignore + + def get( + self, + resource_uri, # type: str + linker_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.LinkerResource" + """Returns Linker resource for a given name. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LinkerResource, or the result of cls(response) + :rtype: ~microsoft_service_linker.models.LinkerResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_uri, # type: str + linker_name, # type: str + parameters, # type: "_models.LinkerResource" + **kwargs # type: Any + ): + # type: (...) -> "_models.LinkerResource" + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LinkerResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def begin_create_or_update( + self, + resource_uri, # type: str + linker_name, # type: str + parameters, # type: "_models.LinkerResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LinkerResource"] + """Create or update linker resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :param parameters: Linker details. + :type parameters: ~microsoft_service_linker.models.LinkerResource + :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 LinkerResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_service_linker.models.LinkerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_uri=resource_uri, + linker_name=linker_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def _delete_initial( + self, + resource_uri, # type: str + linker_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def begin_delete( + self, + resource_uri, # type: str + linker_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete a link. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_uri=resource_uri, + linker_name=linker_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def _update_initial( + self, + resource_uri, # type: str + linker_name, # type: str + parameters, # type: "_models.LinkerPatch" + **kwargs # type: Any + ): + # type: (...) -> "_models.LinkerResource" + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LinkerPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def begin_update( + self, + resource_uri, # type: str + linker_name, # type: str + parameters, # type: "_models.LinkerPatch" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LinkerResource"] + """Operation to update an existing link. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :param parameters: Linker details. + :type parameters: ~microsoft_service_linker.models.LinkerPatch + :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 LinkerResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_service_linker.models.LinkerResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkerResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_uri=resource_uri, + linker_name=linker_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LinkerResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}'} # type: ignore + + def _validate_initial( + self, + resource_uri, # type: str + linker_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.ValidateResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self._validate_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_initial.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker'} # type: ignore + + def begin_validate( + self, + resource_uri, # type: str + linker_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ValidateResult"] + """Validate a link. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_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 ValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_service_linker.models.ValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_initial( + resource_uri=resource_uri, + linker_name=linker_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker'} # type: ignore + + def list_configurations( + self, + resource_uri, # type: str + linker_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SourceConfigurationResult" + """list source configurations for a linker. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param linker_name: The name Linker resource. + :type linker_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceConfigurationResult, or the result of cls(response) + :rtype: ~microsoft_service_linker.models.SourceConfigurationResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceConfigurationResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_configurations.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'linkerName': self._serialize.url("linker_name", linker_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SourceConfigurationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_configurations.metadata = {'url': '/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations'} # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py new file mode 100644 index 000000000000..447bec40dd00 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_service_linker.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationListResult"] + """Lists the available ServiceLinker REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_service_linker.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-11-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.ServiceLinker/operations'} # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/py.typed b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/sdk_packaging.toml b/sdk/servicelinker/azure-mgmt-servicelinker/sdk_packaging.toml new file mode 100644 index 000000000000..9efa23ccc7d6 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-servicelinker" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/setup.cfg b/sdk/servicelinker/azure-mgmt-servicelinker/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/setup.py b/sdk/servicelinker/azure-mgmt-servicelinker/setup.py new file mode 100644 index 000000000000..3a7829da7cea --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/setup.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-servicelinker" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +) diff --git a/sdk/servicelinker/ci.yml b/sdk/servicelinker/ci.yml new file mode 100644 index 000000000000..7a5b0ee9e7ed --- /dev/null +++ b/sdk/servicelinker/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/servicelinker/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/servicelinker/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: servicelinker + Artifacts: + - name: azure-mgmt-servicelinker + safeName: azuremgmtservicelinker