diff --git a/sdk/workloads/azure-mgmt-workloads/CHANGELOG.md b/sdk/workloads/azure-mgmt-workloads/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/workloads/azure-mgmt-workloads/LICENSE b/sdk/workloads/azure-mgmt-workloads/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/workloads/azure-mgmt-workloads/MANIFEST.in b/sdk/workloads/azure-mgmt-workloads/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE diff --git a/sdk/workloads/azure-mgmt-workloads/README.md b/sdk/workloads/azure-mgmt-workloads/README.md new file mode 100644 index 000000000000..32219a1f460a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-workloads%2FREADME.png) diff --git a/sdk/workloads/azure-mgmt-workloads/_meta.json b/sdk/workloads/azure-mgmt-workloads/_meta.json new file mode 100644 index 000000000000..95206ddf1c5c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "4f4a1f9a0b8d8468733f03f2529d0964d3666cf8", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/workloads/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/workloads/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloads/azure/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py new file mode 100644 index 000000000000..8f2b5059c9df --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._workloads_client import WorkloadsClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['WorkloadsClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py new file mode 100644 index 000000000000..bef7edc93f1c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class WorkloadsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for WorkloadsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(WorkloadsClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-workloads/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_metadata.json b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_metadata.json new file mode 100644 index 000000000000..e2792dcba442 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2021-12-01-preview", + "total_api_version_list": ["2021-12-01-preview"], + "client": { + "name": "WorkloadsClient", + "filename": "_workloads_client", + "description": "Workloads client provides access to various workload operations.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"WorkloadsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"WorkloadsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "monitors": "MonitorsOperations", + "provider_instances": "ProviderInstancesOperations" + } +} \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_version.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_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/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py new file mode 100644 index 000000000000..8537ffbfce79 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import WorkloadsClientConfiguration +from .operations import MonitorsOperations, Operations, ProviderInstancesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class WorkloadsClient: + """Workloads client provides access to various workload operations. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.workloads.operations.Operations + :ivar monitors: MonitorsOperations operations + :vartype monitors: azure.mgmt.workloads.operations.MonitorsOperations + :ivar provider_instances: ProviderInstancesOperations operations + :vartype provider_instances: azure.mgmt.workloads.operations.ProviderInstancesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = WorkloadsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_instances = ProviderInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> WorkloadsClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py new file mode 100644 index 000000000000..0d869187c5dd --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._workloads_client import WorkloadsClient +__all__ = ['WorkloadsClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py new file mode 100644 index 000000000000..61293a606e85 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class WorkloadsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for WorkloadsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(WorkloadsClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-workloads/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py new file mode 100644 index 000000000000..724c2d387cfe --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import WorkloadsClientConfiguration +from .operations import MonitorsOperations, Operations, ProviderInstancesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class WorkloadsClient: + """Workloads client provides access to various workload operations. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.workloads.aio.operations.Operations + :ivar monitors: MonitorsOperations operations + :vartype monitors: azure.mgmt.workloads.aio.operations.MonitorsOperations + :ivar provider_instances: ProviderInstancesOperations operations + :vartype provider_instances: azure.mgmt.workloads.aio.operations.ProviderInstancesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = WorkloadsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_instances = ProviderInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "WorkloadsClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py new file mode 100644 index 000000000000..82cf79dd35d7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._monitors_operations import MonitorsOperations +from ._provider_instances_operations import ProviderInstancesOperations + +__all__ = [ + 'Operations', + 'MonitorsOperations', + 'ProviderInstancesOperations', +] diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py new file mode 100644 index 000000000000..f4a35cde05d6 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py @@ -0,0 +1,578 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._monitors_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MonitorsOperations: + """MonitorsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.workloads.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.MonitorListResult"]: + """Gets a list of SAP monitors in the specified subscription. + + Gets a list of SAP monitors in the specified subscription. The operations returns various + properties of each SAP monitor. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitorListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.MonitorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MonitorListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.MonitorListResult"]: + """Gets a list of SAP monitors. + + Gets a list of SAP monitors in the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitorListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.MonitorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MonitorListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> "_models.Monitor": + """Gets properties of a SAP monitor. + + Gets properties of a SAP monitor for the specified subscription, resource group, and resource + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor, or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Monitor', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + + async def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + monitor_parameter: "_models.Monitor", + **kwargs: Any + ) -> "_models.Monitor": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(monitor_parameter, 'Monitor') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Monitor', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Monitor', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + monitor_parameter: "_models.Monitor", + **kwargs: Any + ) -> AsyncLROPoller["_models.Monitor"]: + """Creates a SAP monitor. + + Creates a SAP monitor for the specified subscription, resource group, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param monitor_parameter: Request body representing a SAP Monitor. + :type monitor_parameter: ~azure.mgmt.workloads.models.Monitor + :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 Monitor or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.Monitor] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + 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_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + monitor_parameter=monitor_parameter, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Monitor', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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 + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> Optional["_models.OperationStatusResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncLROPoller["_models.OperationStatusResult"]: + """Deletes a SAP monitor. + + Deletes a SAP monitor with the specified subscription, resource group, and monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_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 OperationStatusResult or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **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 + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + monitor_name: str, + tags_parameter: "_models.Tags", + **kwargs: Any + ) -> "_models.Monitor": + """Patches the Tags field of a SAP monitor. + + Patches the Tags field of a SAP monitor for the specified subscription, resource group, and + monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param tags_parameter: Request body that only contains the new Tags field. + :type tags_parameter: ~azure.mgmt.workloads.models.Tags + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor, or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(tags_parameter, 'Tags') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Monitor', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py new file mode 100644 index 000000000000..762c5bd0ae57 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py @@ -0,0 +1,116 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.workloads.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists all the available API operations under this PR. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Workloads/operations"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py new file mode 100644 index 000000000000..a68831d23912 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py @@ -0,0 +1,460 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._provider_instances_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProviderInstancesOperations: + """ProviderInstancesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.workloads.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ProviderInstanceListResult"]: + """Gets a list of provider instances in the specified SAP monitor. + + Gets a list of provider instances in the specified SAP monitor. The operations returns various + properties of each provider instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProviderInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.ProviderInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProviderInstanceListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any + ) -> "_models.ProviderInstance": + """Gets properties of a provider instance. + + Gets properties of a provider instance for the specified subscription, resource group, Monitor + name, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. + :type provider_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProviderInstance, or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.ProviderInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ProviderInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + + async def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: "_models.ProviderInstance", + **kwargs: Any + ) -> "_models.ProviderInstance": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(provider_instance_parameter, 'ProviderInstance') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ProviderInstance', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ProviderInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: "_models.ProviderInstance", + **kwargs: Any + ) -> AsyncLROPoller["_models.ProviderInstance"]: + """Creates a provider instance. + + Creates a provider instance for the specified subscription, resource group, Monitor name, and + resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. + :type provider_instance_name: str + :param provider_instance_parameter: Request body representing a provider instance. + :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance + :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 ProviderInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.ProviderInstance] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + 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_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + provider_instance_parameter=provider_instance_parameter, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ProviderInstance', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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 + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any + ) -> Optional["_models.OperationStatusResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any + ) -> AsyncLROPoller["_models.OperationStatusResult"]: + """Deletes a provider instance. + + Deletes a provider instance for the specified subscription, resource group, Monitor name, and + resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. + :type provider_instance_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 OperationStatusResult or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **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 + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py new file mode 100644 index 000000000000..facea6958c97 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import DB2ProviderInstanceProperties +from ._models_py3 import Error +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorInnerError +from ._models_py3 import ErrorResponse +from ._models_py3 import HanaDbProviderInstanceProperties +from ._models_py3 import ManagedRGConfiguration +from ._models_py3 import Monitor +from ._models_py3 import MonitorListResult +from ._models_py3 import MonitorPropertiesErrors +from ._models_py3 import MsSqlServerProviderInstanceProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationStatusResult +from ._models_py3 import OperationsContent +from ._models_py3 import OperationsDefinition +from ._models_py3 import OperationsDefinitionArrayResponseWithContinuation +from ._models_py3 import OperationsDefinitionDisplay +from ._models_py3 import OperationsDisplayDefinition +from ._models_py3 import PrometheusHaClusterProviderInstanceProperties +from ._models_py3 import PrometheusOSProviderInstanceProperties +from ._models_py3 import ProviderInstance +from ._models_py3 import ProviderInstanceListResult +from ._models_py3 import ProviderInstancePropertiesErrors +from ._models_py3 import ProviderSpecificProperties +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import SapNetWeaverProviderInstanceProperties +from ._models_py3 import SystemData +from ._models_py3 import Tags +from ._models_py3 import TrackedResource + + +from ._workloads_client_enums import ( + ActionType, + CreatedByType, + OperationProperties, + Origin, + RoutingPreference, + WorkloadMonitorActionType, + WorkloadMonitorProvisioningState, +) + +__all__ = [ + 'DB2ProviderInstanceProperties', + 'Error', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorInnerError', + 'ErrorResponse', + 'HanaDbProviderInstanceProperties', + 'ManagedRGConfiguration', + 'Monitor', + 'MonitorListResult', + 'MonitorPropertiesErrors', + 'MsSqlServerProviderInstanceProperties', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'OperationStatusResult', + 'OperationsContent', + 'OperationsDefinition', + 'OperationsDefinitionArrayResponseWithContinuation', + 'OperationsDefinitionDisplay', + 'OperationsDisplayDefinition', + 'PrometheusHaClusterProviderInstanceProperties', + 'PrometheusOSProviderInstanceProperties', + 'ProviderInstance', + 'ProviderInstanceListResult', + 'ProviderInstancePropertiesErrors', + 'ProviderSpecificProperties', + 'ProxyResource', + 'Resource', + 'SapNetWeaverProviderInstanceProperties', + 'SystemData', + 'Tags', + 'TrackedResource', + 'ActionType', + 'CreatedByType', + 'OperationProperties', + 'Origin', + 'RoutingPreference', + 'WorkloadMonitorActionType', + 'WorkloadMonitorProvisioningState', +] diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py new file mode 100644 index 000000000000..cf8d29681070 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py @@ -0,0 +1,1759 @@ +# 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 Any, Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._workloads_client_enums import * + + +class ProviderSpecificProperties(msrest.serialization.Model): + """Gets or sets the provider specific properties. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: DB2ProviderInstanceProperties, MsSqlServerProviderInstanceProperties, PrometheusHaClusterProviderInstanceProperties, PrometheusOSProviderInstanceProperties, HanaDbProviderInstanceProperties, SapNetWeaverProviderInstanceProperties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + } + + _subtype_map = { + 'provider_type': {'Db2': 'DB2ProviderInstanceProperties', 'MsSqlServer': 'MsSqlServerProviderInstanceProperties', 'PrometheusHaCluster': 'PrometheusHaClusterProviderInstanceProperties', 'PrometheusOS': 'PrometheusOSProviderInstanceProperties', 'SapHana': 'HanaDbProviderInstanceProperties', 'SapNetWeaver': 'SapNetWeaverProviderInstanceProperties'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProviderSpecificProperties, self).__init__(**kwargs) + self.provider_type = None # type: Optional[str] + + +class DB2ProviderInstanceProperties(ProviderSpecificProperties): + """Gets or sets the DB2 provider properties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + :ivar hostname: Gets or sets the target virtual machine name. + :vartype hostname: str + :ivar db_name: Gets or sets the db2 database name. + :vartype db_name: str + :ivar db_port: Gets or sets the db2 database sql port. + :vartype db_port: str + :ivar db_username: Gets or sets the db2 database user name. + :vartype db_username: str + :ivar db_password: Gets or sets the db2 database password. + :vartype db_password: str + :ivar db_password_uri: Gets or sets the key vault URI to secret with the database password. + :vartype db_password_uri: str + :ivar sap_sid: Gets or sets the SAP System Identifier. + :vartype sap_sid: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + 'hostname': {'key': 'hostname', 'type': 'str'}, + 'db_name': {'key': 'dbName', 'type': 'str'}, + 'db_port': {'key': 'dbPort', 'type': 'str'}, + 'db_username': {'key': 'dbUsername', 'type': 'str'}, + 'db_password': {'key': 'dbPassword', 'type': 'str'}, + 'db_password_uri': {'key': 'dbPasswordUri', 'type': 'str'}, + 'sap_sid': {'key': 'sapSid', 'type': 'str'}, + } + + def __init__( + self, + *, + hostname: Optional[str] = None, + db_name: Optional[str] = None, + db_port: Optional[str] = None, + db_username: Optional[str] = None, + db_password: Optional[str] = None, + db_password_uri: Optional[str] = None, + sap_sid: Optional[str] = None, + **kwargs + ): + """ + :keyword hostname: Gets or sets the target virtual machine name. + :paramtype hostname: str + :keyword db_name: Gets or sets the db2 database name. + :paramtype db_name: str + :keyword db_port: Gets or sets the db2 database sql port. + :paramtype db_port: str + :keyword db_username: Gets or sets the db2 database user name. + :paramtype db_username: str + :keyword db_password: Gets or sets the db2 database password. + :paramtype db_password: str + :keyword db_password_uri: Gets or sets the key vault URI to secret with the database password. + :paramtype db_password_uri: str + :keyword sap_sid: Gets or sets the SAP System Identifier. + :paramtype sap_sid: str + """ + super(DB2ProviderInstanceProperties, self).__init__(**kwargs) + self.provider_type = 'Db2' # type: str + self.hostname = hostname + self.db_name = db_name + self.db_port = db_port + self.db_username = db_username + self.db_password = db_password + self.db_password_uri = db_password_uri + self.sap_sid = sap_sid + + +class Error(msrest.serialization.Model): + """Standard error object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Server-defined set of error codes. + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar target: Target of the error. + :vartype target: str + :ivar details: Array of details about specific errors that led to this reported error. + :vartype details: list[~azure.mgmt.workloads.models.Error] + :ivar inner_error: Object containing more specific information than the current object about + the error. + :vartype inner_error: ~azure.mgmt.workloads.models.ErrorInnerError + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'inner_error': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'ErrorInnerError'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Error, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.inner_error = None + + +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[~azure.mgmt.workloads.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.workloads.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 ErrorInnerError(msrest.serialization.Model): + """Object containing more specific information than the current object about the error. + + :ivar inner_error: Standard error object. + :vartype inner_error: ~azure.mgmt.workloads.models.Error + """ + + _attribute_map = { + 'inner_error': {'key': 'innerError', 'type': 'Error'}, + } + + def __init__( + self, + *, + inner_error: Optional["Error"] = None, + **kwargs + ): + """ + :keyword inner_error: Standard error object. + :paramtype inner_error: ~azure.mgmt.workloads.models.Error + """ + super(ErrorInnerError, self).__init__(**kwargs) + self.inner_error = inner_error + + +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.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.workloads.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.workloads.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class HanaDbProviderInstanceProperties(ProviderSpecificProperties): + """Gets or sets the provider properties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + :ivar hostname: Gets or sets the target virtual machine size. + :vartype hostname: str + :ivar db_name: Gets or sets the hana database name. + :vartype db_name: str + :ivar sql_port: Gets or sets the database sql port. + :vartype sql_port: str + :ivar instance_number: Gets or sets the database instance number. + :vartype instance_number: str + :ivar db_username: Gets or sets the database user name. + :vartype db_username: str + :ivar db_password: Gets or sets the database password. + :vartype db_password: str + :ivar db_password_uri: Gets or sets the key vault URI to secret with the database password. + :vartype db_password_uri: str + :ivar db_ssl_certificate_uri: Gets or sets the blob URI to SSL certificate for the DB. + :vartype db_ssl_certificate_uri: str + :ivar ssl_host_name_in_certificate: Gets or sets the hostname(s) in the SSL certificate. + :vartype ssl_host_name_in_certificate: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + 'hostname': {'key': 'hostname', 'type': 'str'}, + 'db_name': {'key': 'dbName', 'type': 'str'}, + 'sql_port': {'key': 'sqlPort', 'type': 'str'}, + 'instance_number': {'key': 'instanceNumber', 'type': 'str'}, + 'db_username': {'key': 'dbUsername', 'type': 'str'}, + 'db_password': {'key': 'dbPassword', 'type': 'str'}, + 'db_password_uri': {'key': 'dbPasswordUri', 'type': 'str'}, + 'db_ssl_certificate_uri': {'key': 'dbSslCertificateUri', 'type': 'str'}, + 'ssl_host_name_in_certificate': {'key': 'sslHostNameInCertificate', 'type': 'str'}, + } + + def __init__( + self, + *, + hostname: Optional[str] = None, + db_name: Optional[str] = None, + sql_port: Optional[str] = None, + instance_number: Optional[str] = None, + db_username: Optional[str] = None, + db_password: Optional[str] = None, + db_password_uri: Optional[str] = None, + db_ssl_certificate_uri: Optional[str] = None, + ssl_host_name_in_certificate: Optional[str] = None, + **kwargs + ): + """ + :keyword hostname: Gets or sets the target virtual machine size. + :paramtype hostname: str + :keyword db_name: Gets or sets the hana database name. + :paramtype db_name: str + :keyword sql_port: Gets or sets the database sql port. + :paramtype sql_port: str + :keyword instance_number: Gets or sets the database instance number. + :paramtype instance_number: str + :keyword db_username: Gets or sets the database user name. + :paramtype db_username: str + :keyword db_password: Gets or sets the database password. + :paramtype db_password: str + :keyword db_password_uri: Gets or sets the key vault URI to secret with the database password. + :paramtype db_password_uri: str + :keyword db_ssl_certificate_uri: Gets or sets the blob URI to SSL certificate for the DB. + :paramtype db_ssl_certificate_uri: str + :keyword ssl_host_name_in_certificate: Gets or sets the hostname(s) in the SSL certificate. + :paramtype ssl_host_name_in_certificate: str + """ + super(HanaDbProviderInstanceProperties, self).__init__(**kwargs) + self.provider_type = 'SapHana' # type: str + self.hostname = hostname + self.db_name = db_name + self.sql_port = sql_port + self.instance_number = instance_number + self.db_username = db_username + self.db_password = db_password + self.db_password_uri = db_password_uri + self.db_ssl_certificate_uri = db_ssl_certificate_uri + self.ssl_host_name_in_certificate = ssl_host_name_in_certificate + + +class ManagedRGConfiguration(msrest.serialization.Model): + """Managed resource group configuration. + + :ivar name: Managed resource group name. + :vartype name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Managed resource group name. + :paramtype name: str + """ + super(ManagedRGConfiguration, self).__init__(**kwargs) + self.name = name + + +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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.workloads.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: 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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.workloads.models.SystemData + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class Monitor(TrackedResource): + """SAP monitor info on Azure (ARM properties and SAP monitor properties). + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: 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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.workloads.models.SystemData + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar provisioning_state: State of provisioning of the monitor. Possible values include: + "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :vartype provisioning_state: str or + ~azure.mgmt.workloads.models.WorkloadMonitorProvisioningState + :ivar errors: Defines the SAP monitor errors. + :vartype errors: ~azure.mgmt.workloads.models.MonitorPropertiesErrors + :ivar app_location: The monitor resources will be deployed in the monitoring region. The subnet + region should be same as the monitoring region. + :vartype app_location: str + :ivar routing_preference: Sets the routing preference of the monitor. By default only RFC1918 + traffic is routed to the customer VNET. Possible values include: "Default", "RouteAll". + :vartype routing_preference: str or ~azure.mgmt.workloads.models.RoutingPreference + :ivar managed_resource_group_configuration: Managed resource group configuration. + :vartype managed_resource_group_configuration: + ~azure.mgmt.workloads.models.ManagedRGConfiguration + :ivar log_analytics_workspace_arm_id: The ARM ID of the Log Analytics Workspace that is used + for monitoring. + :vartype log_analytics_workspace_arm_id: str + :ivar monitor_subnet: The subnet which the SAP monitor will be deployed in. + :vartype monitor_subnet: str + :ivar msi_arm_id: The ARM ID of the MSI used for monitoring. + :vartype msi_arm_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'location': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'errors': {'readonly': True}, + 'msi_arm_id': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'errors': {'key': 'properties.errors', 'type': 'MonitorPropertiesErrors'}, + 'app_location': {'key': 'properties.appLocation', 'type': 'str'}, + 'routing_preference': {'key': 'properties.routingPreference', 'type': 'str'}, + 'managed_resource_group_configuration': {'key': 'properties.managedResourceGroupConfiguration', 'type': 'ManagedRGConfiguration'}, + 'log_analytics_workspace_arm_id': {'key': 'properties.logAnalyticsWorkspaceArmId', 'type': 'str'}, + 'monitor_subnet': {'key': 'properties.monitorSubnet', 'type': 'str'}, + 'msi_arm_id': {'key': 'properties.msiArmId', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + app_location: Optional[str] = None, + routing_preference: Optional[Union[str, "RoutingPreference"]] = None, + managed_resource_group_configuration: Optional["ManagedRGConfiguration"] = None, + log_analytics_workspace_arm_id: Optional[str] = None, + monitor_subnet: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword app_location: The monitor resources will be deployed in the monitoring region. The + subnet region should be same as the monitoring region. + :paramtype app_location: str + :keyword routing_preference: Sets the routing preference of the monitor. By default only + RFC1918 traffic is routed to the customer VNET. Possible values include: "Default", "RouteAll". + :paramtype routing_preference: str or ~azure.mgmt.workloads.models.RoutingPreference + :keyword managed_resource_group_configuration: Managed resource group configuration. + :paramtype managed_resource_group_configuration: + ~azure.mgmt.workloads.models.ManagedRGConfiguration + :keyword log_analytics_workspace_arm_id: The ARM ID of the Log Analytics Workspace that is used + for monitoring. + :paramtype log_analytics_workspace_arm_id: str + :keyword monitor_subnet: The subnet which the SAP monitor will be deployed in. + :paramtype monitor_subnet: str + """ + super(Monitor, self).__init__(tags=tags, location=location, **kwargs) + self.provisioning_state = None + self.errors = None + self.app_location = app_location + self.routing_preference = routing_preference + self.managed_resource_group_configuration = managed_resource_group_configuration + self.log_analytics_workspace_arm_id = log_analytics_workspace_arm_id + self.monitor_subnet = monitor_subnet + self.msi_arm_id = None + + +class MonitorListResult(msrest.serialization.Model): + """The response from the List SAP monitors operation. + + :ivar value: The list of SAP monitors. + :vartype value: list[~azure.mgmt.workloads.models.Monitor] + :ivar next_link: The URL to get the next set of SAP monitors. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Monitor]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Monitor"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of SAP monitors. + :paramtype value: list[~azure.mgmt.workloads.models.Monitor] + :keyword next_link: The URL to get the next set of SAP monitors. + :paramtype next_link: str + """ + super(MonitorListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MonitorPropertiesErrors(Error): + """Defines the SAP monitor errors. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Server-defined set of error codes. + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar target: Target of the error. + :vartype target: str + :ivar details: Array of details about specific errors that led to this reported error. + :vartype details: list[~azure.mgmt.workloads.models.Error] + :ivar inner_error: Object containing more specific information than the current object about + the error. + :vartype inner_error: ~azure.mgmt.workloads.models.ErrorInnerError + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'inner_error': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'ErrorInnerError'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(MonitorPropertiesErrors, self).__init__(**kwargs) + + +class MsSqlServerProviderInstanceProperties(ProviderSpecificProperties): + """Gets or sets the SQL server provider properties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + :ivar hostname: Gets or sets the SQL server host name. + :vartype hostname: str + :ivar db_port: Gets or sets the database sql port. + :vartype db_port: str + :ivar db_username: Gets or sets the database user name. + :vartype db_username: str + :ivar db_password: Gets or sets the database password. + :vartype db_password: str + :ivar db_password_uri: Gets or sets the key vault URI to secret with the database password. + :vartype db_password_uri: str + :ivar sap_sid: Gets or sets the SAP System Identifier. + :vartype sap_sid: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + 'hostname': {'key': 'hostname', 'type': 'str'}, + 'db_port': {'key': 'dbPort', 'type': 'str'}, + 'db_username': {'key': 'dbUsername', 'type': 'str'}, + 'db_password': {'key': 'dbPassword', 'type': 'str'}, + 'db_password_uri': {'key': 'dbPasswordUri', 'type': 'str'}, + 'sap_sid': {'key': 'sapSid', 'type': 'str'}, + } + + def __init__( + self, + *, + hostname: Optional[str] = None, + db_port: Optional[str] = None, + db_username: Optional[str] = None, + db_password: Optional[str] = None, + db_password_uri: Optional[str] = None, + sap_sid: Optional[str] = None, + **kwargs + ): + """ + :keyword hostname: Gets or sets the SQL server host name. + :paramtype hostname: str + :keyword db_port: Gets or sets the database sql port. + :paramtype db_port: str + :keyword db_username: Gets or sets the database user name. + :paramtype db_username: str + :keyword db_password: Gets or sets the database password. + :paramtype db_password: str + :keyword db_password_uri: Gets or sets the key vault URI to secret with the database password. + :paramtype db_password_uri: str + :keyword sap_sid: Gets or sets the SAP System Identifier. + :paramtype sap_sid: str + """ + super(MsSqlServerProviderInstanceProperties, self).__init__(**kwargs) + self.provider_type = 'MsSqlServer' # type: str + self.hostname = hostname + self.db_port = db_port + self.db_username = db_username + self.db_password = db_password + self.db_password_uri = db_password_uri + self.sap_sid = sap_sid + + +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 + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.workloads.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 ~azure.mgmt.workloads.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 ~azure.mgmt.workloads.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 + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.workloads.models.OperationDisplay + """ + 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[~azure.mgmt.workloads.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 OperationsContent(Resource): + """Defines the workload operation content. + + 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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.workloads.models.SystemData + :ivar name_properties_name: Name of the operation. + :vartype name_properties_name: str + :ivar is_data_action: Indicates whether the operation applies to data-plane. + :vartype is_data_action: bool + :ivar origin: Defines the workload operation origin. Possible values include: "NotSpecified", + "User", "System". + :vartype origin: str or ~azure.mgmt.workloads.models.OperationProperties + :ivar display: Display information of the operation. + :vartype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay + :ivar action_type: Defines the action type of workload operation. Possible values include: + "NotSpecified", "Internal". + :vartype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType + :ivar properties: Defines the workload operation properties. + :vartype properties: any + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, + 'is_data_action': {'key': 'properties.isDataAction', 'type': 'bool'}, + 'origin': {'key': 'properties.origin', 'type': 'str'}, + 'display': {'key': 'properties.display', 'type': 'OperationsDefinitionDisplay'}, + 'action_type': {'key': 'properties.actionType', 'type': 'str'}, + 'properties': {'key': 'properties.properties', 'type': 'object'}, + } + + def __init__( + self, + *, + name_properties_name: Optional[str] = None, + is_data_action: Optional[bool] = None, + origin: Optional[Union[str, "OperationProperties"]] = None, + display: Optional["OperationsDefinitionDisplay"] = None, + action_type: Optional[Union[str, "WorkloadMonitorActionType"]] = None, + properties: Optional[Any] = None, + **kwargs + ): + """ + :keyword name_properties_name: Name of the operation. + :paramtype name_properties_name: str + :keyword is_data_action: Indicates whether the operation applies to data-plane. + :paramtype is_data_action: bool + :keyword origin: Defines the workload operation origin. Possible values include: + "NotSpecified", "User", "System". + :paramtype origin: str or ~azure.mgmt.workloads.models.OperationProperties + :keyword display: Display information of the operation. + :paramtype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay + :keyword action_type: Defines the action type of workload operation. Possible values include: + "NotSpecified", "Internal". + :paramtype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType + :keyword properties: Defines the workload operation properties. + :paramtype properties: any + """ + super(OperationsContent, self).__init__(**kwargs) + self.name_properties_name = name_properties_name + self.is_data_action = is_data_action + self.origin = origin + self.display = display + self.action_type = action_type + self.properties = properties + + +class OperationsDefinition(msrest.serialization.Model): + """Properties of an Operation. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation applies to data-plane. + :vartype is_data_action: bool + :ivar origin: Defines the workload operation origin. Possible values include: "NotSpecified", + "User", "System". + :vartype origin: str or ~azure.mgmt.workloads.models.OperationProperties + :ivar display: Required. Display information of the operation. + :vartype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay + :ivar action_type: Defines the action type of workload operation. Possible values include: + "NotSpecified", "Internal". + :vartype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType + :ivar properties: Defines the workload operation properties. + :vartype properties: any + """ + + _validation = { + 'name': {'required': True}, + 'display': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationsDefinitionDisplay'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'object'}, + } + + def __init__( + self, + *, + name: str, + display: "OperationsDefinitionDisplay", + is_data_action: Optional[bool] = None, + origin: Optional[Union[str, "OperationProperties"]] = None, + action_type: Optional[Union[str, "WorkloadMonitorActionType"]] = None, + properties: Optional[Any] = None, + **kwargs + ): + """ + :keyword name: Required. Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation applies to data-plane. + :paramtype is_data_action: bool + :keyword origin: Defines the workload operation origin. Possible values include: + "NotSpecified", "User", "System". + :paramtype origin: str or ~azure.mgmt.workloads.models.OperationProperties + :keyword display: Required. Display information of the operation. + :paramtype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay + :keyword action_type: Defines the action type of workload operation. Possible values include: + "NotSpecified", "Internal". + :paramtype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType + :keyword properties: Defines the workload operation properties. + :paramtype properties: any + """ + super(OperationsDefinition, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.origin = origin + self.display = display + self.action_type = action_type + self.properties = properties + + +class OperationsDefinitionArrayResponseWithContinuation(msrest.serialization.Model): + """Defines the workload operation definition response. + + :ivar value: Defines the workload operation definition response properties. + :vartype value: list[~azure.mgmt.workloads.models.OperationsDefinition] + :ivar next_link: The URL to get to the next set of results, if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationsDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OperationsDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Defines the workload operation definition response properties. + :paramtype value: list[~azure.mgmt.workloads.models.OperationsDefinition] + :keyword next_link: The URL to get to the next set of results, if there are any. + :paramtype next_link: str + """ + super(OperationsDefinitionArrayResponseWithContinuation, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationsDisplayDefinition(msrest.serialization.Model): + """Defines the workload operation. + + All required parameters must be populated in order to send to Azure. + + :ivar provider: Required. Defines the workload provider. + :vartype provider: str + :ivar resource: Required. Defines the workload resource. + :vartype resource: str + :ivar operation: Required. Defines the workload operation. + :vartype operation: str + :ivar description: Required. Describes the workload operation. + :vartype description: str + """ + + _validation = { + 'provider': {'required': True}, + 'resource': {'required': True}, + 'operation': {'required': True}, + 'description': {'required': 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, + *, + provider: str, + resource: str, + operation: str, + description: str, + **kwargs + ): + """ + :keyword provider: Required. Defines the workload provider. + :paramtype provider: str + :keyword resource: Required. Defines the workload resource. + :paramtype resource: str + :keyword operation: Required. Defines the workload operation. + :paramtype operation: str + :keyword description: Required. Describes the workload operation. + :paramtype description: str + """ + super(OperationsDisplayDefinition, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationsDefinitionDisplay(OperationsDisplayDefinition): + """Display information of the operation. + + All required parameters must be populated in order to send to Azure. + + :ivar provider: Required. Defines the workload provider. + :vartype provider: str + :ivar resource: Required. Defines the workload resource. + :vartype resource: str + :ivar operation: Required. Defines the workload operation. + :vartype operation: str + :ivar description: Required. Describes the workload operation. + :vartype description: str + """ + + _validation = { + 'provider': {'required': True}, + 'resource': {'required': True}, + 'operation': {'required': True}, + 'description': {'required': 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, + *, + provider: str, + resource: str, + operation: str, + description: str, + **kwargs + ): + """ + :keyword provider: Required. Defines the workload provider. + :paramtype provider: str + :keyword resource: Required. Defines the workload resource. + :paramtype resource: str + :keyword operation: Required. Defines the workload operation. + :paramtype operation: str + :keyword description: Required. Describes the workload operation. + :paramtype description: str + """ + super(OperationsDefinitionDisplay, self).__init__(provider=provider, resource=resource, operation=operation, description=description, **kwargs) + + +class OperationStatusResult(msrest.serialization.Model): + """The current status of an async operation. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Required. Operation status. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.workloads.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.workloads.models.ErrorDetail + """ + + _validation = { + 'status': {'required': True}, + 'percent_complete': {'maximum': 100, 'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'operations': {'key': 'operations', 'type': '[OperationStatusResult]'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["OperationStatusResult"]] = None, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Required. Operation status. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.workloads.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.workloads.models.ErrorDetail + """ + super(OperationStatusResult, self).__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.percent_complete = percent_complete + self.start_time = start_time + self.end_time = end_time + self.operations = operations + self.error = error + + +class PrometheusHaClusterProviderInstanceProperties(ProviderSpecificProperties): + """Gets or sets the PrometheusHaCluster provider properties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + :ivar prometheus_url: URL of the Node Exporter endpoint. + :vartype prometheus_url: str + :ivar hostname: Gets or sets the target machine name. + :vartype hostname: str + :ivar sid: Gets or sets the cluster sid. + :vartype sid: str + :ivar cluster_name: Gets or sets the clusterName. + :vartype cluster_name: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + 'prometheus_url': {'key': 'prometheusUrl', 'type': 'str'}, + 'hostname': {'key': 'hostname', 'type': 'str'}, + 'sid': {'key': 'sid', 'type': 'str'}, + 'cluster_name': {'key': 'clusterName', 'type': 'str'}, + } + + def __init__( + self, + *, + prometheus_url: Optional[str] = None, + hostname: Optional[str] = None, + sid: Optional[str] = None, + cluster_name: Optional[str] = None, + **kwargs + ): + """ + :keyword prometheus_url: URL of the Node Exporter endpoint. + :paramtype prometheus_url: str + :keyword hostname: Gets or sets the target machine name. + :paramtype hostname: str + :keyword sid: Gets or sets the cluster sid. + :paramtype sid: str + :keyword cluster_name: Gets or sets the clusterName. + :paramtype cluster_name: str + """ + super(PrometheusHaClusterProviderInstanceProperties, self).__init__(**kwargs) + self.provider_type = 'PrometheusHaCluster' # type: str + self.prometheus_url = prometheus_url + self.hostname = hostname + self.sid = sid + self.cluster_name = cluster_name + + +class PrometheusOSProviderInstanceProperties(ProviderSpecificProperties): + """Gets or sets the PrometheusOS provider properties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + :ivar prometheus_url: URL of the Node Exporter endpoint. + :vartype prometheus_url: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + 'prometheus_url': {'key': 'prometheusUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + prometheus_url: Optional[str] = None, + **kwargs + ): + """ + :keyword prometheus_url: URL of the Node Exporter endpoint. + :paramtype prometheus_url: str + """ + super(PrometheusOSProviderInstanceProperties, self).__init__(**kwargs) + self.provider_type = 'PrometheusOS' # type: str + self.prometheus_url = prometheus_url + + +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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.workloads.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class ProviderInstance(ProxyResource): + """A provider instance associated with monitor. + + 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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.workloads.models.SystemData + :ivar provisioning_state: State of provisioning of the provider instance. Possible values + include: "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :vartype provisioning_state: str or + ~azure.mgmt.workloads.models.WorkloadMonitorProvisioningState + :ivar errors: Defines the provider instance errors. + :vartype errors: ~azure.mgmt.workloads.models.ProviderInstancePropertiesErrors + :ivar provider_settings: Defines the provider instance errors. + :vartype provider_settings: ~azure.mgmt.workloads.models.ProviderSpecificProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'errors': {'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'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'errors': {'key': 'properties.errors', 'type': 'ProviderInstancePropertiesErrors'}, + 'provider_settings': {'key': 'properties.providerSettings', 'type': 'ProviderSpecificProperties'}, + } + + def __init__( + self, + *, + provider_settings: Optional["ProviderSpecificProperties"] = None, + **kwargs + ): + """ + :keyword provider_settings: Defines the provider instance errors. + :paramtype provider_settings: ~azure.mgmt.workloads.models.ProviderSpecificProperties + """ + super(ProviderInstance, self).__init__(**kwargs) + self.provisioning_state = None + self.errors = None + self.provider_settings = provider_settings + + +class ProviderInstanceListResult(msrest.serialization.Model): + """The response from the List provider instances operation. + + :ivar value: The list of provider instances. + :vartype value: list[~azure.mgmt.workloads.models.ProviderInstance] + :ivar next_link: The URL to get the next set of provider instances. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ProviderInstance]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ProviderInstance"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of provider instances. + :paramtype value: list[~azure.mgmt.workloads.models.ProviderInstance] + :keyword next_link: The URL to get the next set of provider instances. + :paramtype next_link: str + """ + super(ProviderInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ProviderInstancePropertiesErrors(Error): + """Defines the provider instance errors. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Server-defined set of error codes. + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar target: Target of the error. + :vartype target: str + :ivar details: Array of details about specific errors that led to this reported error. + :vartype details: list[~azure.mgmt.workloads.models.Error] + :ivar inner_error: Object containing more specific information than the current object about + the error. + :vartype inner_error: ~azure.mgmt.workloads.models.ErrorInnerError + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'inner_error': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'ErrorInnerError'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProviderInstancePropertiesErrors, self).__init__(**kwargs) + + +class SapNetWeaverProviderInstanceProperties(ProviderSpecificProperties): + """Gets or sets the provider properties. + + All required parameters must be populated in order to send to Azure. + + :ivar provider_type: Required. The provider type. For example, the value can be + SapHana.Constant filled by server. + :vartype provider_type: str + :ivar sap_sid: Gets or sets the SAP System Identifier. + :vartype sap_sid: str + :ivar sap_hostname: Gets or sets the target virtual machine IP Address/FQDN. + :vartype sap_hostname: str + :ivar sap_instance_nr: Gets or sets the instance number of SAP NetWeaver. + :vartype sap_instance_nr: str + :ivar sap_host_file_entries: Gets or sets the list of HostFile Entries. + :vartype sap_host_file_entries: list[str] + :ivar sap_username: Gets or sets the SAP user name. + :vartype sap_username: str + :ivar sap_password: Sets the SAP password. + :vartype sap_password: str + :ivar sap_password_uri: Gets or sets the key vault URI to secret with the SAP password. + :vartype sap_password_uri: str + :ivar sap_client_id: Gets or sets the SAP Client ID. + :vartype sap_client_id: str + :ivar sap_port_number: Gets or sets the SAP HTTP port number. + :vartype sap_port_number: str + :ivar sap_ssl_certificate_uri: Gets or sets the blob URI to SSL certificate for the SAP system. + :vartype sap_ssl_certificate_uri: str + """ + + _validation = { + 'provider_type': {'required': True}, + } + + _attribute_map = { + 'provider_type': {'key': 'providerType', 'type': 'str'}, + 'sap_sid': {'key': 'sapSid', 'type': 'str'}, + 'sap_hostname': {'key': 'sapHostname', 'type': 'str'}, + 'sap_instance_nr': {'key': 'sapInstanceNr', 'type': 'str'}, + 'sap_host_file_entries': {'key': 'sapHostFileEntries', 'type': '[str]'}, + 'sap_username': {'key': 'sapUsername', 'type': 'str'}, + 'sap_password': {'key': 'sapPassword', 'type': 'str'}, + 'sap_password_uri': {'key': 'sapPasswordUri', 'type': 'str'}, + 'sap_client_id': {'key': 'sapClientId', 'type': 'str'}, + 'sap_port_number': {'key': 'sapPortNumber', 'type': 'str'}, + 'sap_ssl_certificate_uri': {'key': 'sapSslCertificateUri', 'type': 'str'}, + } + + def __init__( + self, + *, + sap_sid: Optional[str] = None, + sap_hostname: Optional[str] = None, + sap_instance_nr: Optional[str] = None, + sap_host_file_entries: Optional[List[str]] = None, + sap_username: Optional[str] = None, + sap_password: Optional[str] = None, + sap_password_uri: Optional[str] = None, + sap_client_id: Optional[str] = None, + sap_port_number: Optional[str] = None, + sap_ssl_certificate_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword sap_sid: Gets or sets the SAP System Identifier. + :paramtype sap_sid: str + :keyword sap_hostname: Gets or sets the target virtual machine IP Address/FQDN. + :paramtype sap_hostname: str + :keyword sap_instance_nr: Gets or sets the instance number of SAP NetWeaver. + :paramtype sap_instance_nr: str + :keyword sap_host_file_entries: Gets or sets the list of HostFile Entries. + :paramtype sap_host_file_entries: list[str] + :keyword sap_username: Gets or sets the SAP user name. + :paramtype sap_username: str + :keyword sap_password: Sets the SAP password. + :paramtype sap_password: str + :keyword sap_password_uri: Gets or sets the key vault URI to secret with the SAP password. + :paramtype sap_password_uri: str + :keyword sap_client_id: Gets or sets the SAP Client ID. + :paramtype sap_client_id: str + :keyword sap_port_number: Gets or sets the SAP HTTP port number. + :paramtype sap_port_number: str + :keyword sap_ssl_certificate_uri: Gets or sets the blob URI to SSL certificate for the SAP + system. + :paramtype sap_ssl_certificate_uri: str + """ + super(SapNetWeaverProviderInstanceProperties, self).__init__(**kwargs) + self.provider_type = 'SapNetWeaver' # type: str + self.sap_sid = sap_sid + self.sap_hostname = sap_hostname + self.sap_instance_nr = sap_instance_nr + self.sap_host_file_entries = sap_host_file_entries + self.sap_username = sap_username + self.sap_password = sap_password + self.sap_password_uri = sap_password_uri + self.sap_client_id = sap_client_id + self.sap_port_number = sap_port_number + self.sap_ssl_certificate_uri = sap_ssl_certificate_uri + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.workloads.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.workloads.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "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 + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.workloads.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.workloads.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + 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 Tags(msrest.serialization.Model): + """Tags field of the resource. + + :ivar tags: A set of tags. Tags field of the resource. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Tags field of the resource. + :paramtype tags: dict[str, str] + """ + super(Tags, self).__init__(**kwargs) + self.tags = tags diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py new file mode 100644 index 000000000000..0375f8335a9d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +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 CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class OperationProperties(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Defines the workload operation origin. + """ + + NOT_SPECIFIED = "NotSpecified" + USER = "User" + SYSTEM = "System" + +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" + +class RoutingPreference(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Sets the routing preference of the monitor. By default only RFC1918 traffic is routed to the + customer VNET. + """ + + DEFAULT = "Default" + ROUTE_ALL = "RouteAll" + +class WorkloadMonitorActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Defines the action type of workload operation. + """ + + NOT_SPECIFIED = "NotSpecified" + INTERNAL = "Internal" + +class WorkloadMonitorProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """State of provisioning of the monitor. + """ + + ACCEPTED = "Accepted" + CREATING = "Creating" + UPDATING = "Updating" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + DELETING = "Deleting" + MIGRATING = "Migrating" diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py new file mode 100644 index 000000000000..82cf79dd35d7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._monitors_operations import MonitorsOperations +from ._provider_instances_operations import ProviderInstancesOperations + +__all__ = [ + 'Operations', + 'MonitorsOperations', + 'ProviderInstancesOperations', +] diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py new file mode 100644 index 000000000000..d5b3e2121932 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py @@ -0,0 +1,806 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class MonitorsOperations(object): + """MonitorsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.workloads.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.MonitorListResult"]: + """Gets a list of SAP monitors in the specified subscription. + + Gets a list of SAP monitors in the specified subscription. The operations returns various + properties of each SAP monitor. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitorListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.MonitorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MonitorListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.MonitorListResult"]: + """Gets a list of SAP monitors. + + Gets a list of SAP monitors in the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitorListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.MonitorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MonitorListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> "_models.Monitor": + """Gets properties of a SAP monitor. + + Gets properties of a SAP monitor for the specified subscription, resource group, and resource + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor, or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Monitor', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + + def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + monitor_parameter: "_models.Monitor", + **kwargs: Any + ) -> "_models.Monitor": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(monitor_parameter, 'Monitor') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Monitor', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Monitor', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + monitor_name: str, + monitor_parameter: "_models.Monitor", + **kwargs: Any + ) -> LROPoller["_models.Monitor"]: + """Creates a SAP monitor. + + Creates a SAP monitor for the specified subscription, resource group, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param monitor_parameter: Request body representing a SAP Monitor. + :type monitor_parameter: ~azure.mgmt.workloads.models.Monitor + :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 Monitor or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.Monitor] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + 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_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + monitor_parameter=monitor_parameter, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Monitor', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> Optional["_models.OperationStatusResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> LROPoller["_models.OperationStatusResult"]: + """Deletes a SAP monitor. + + Deletes a SAP monitor with the specified subscription, resource group, and monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_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 OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + monitor_name: str, + tags_parameter: "_models.Tags", + **kwargs: Any + ) -> "_models.Monitor": + """Patches the Tags field of a SAP monitor. + + Patches the Tags field of a SAP monitor for the specified subscription, resource group, and + monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param tags_parameter: Request body that only contains the new Tags field. + :type tags_parameter: ~azure.mgmt.workloads.models.Tags + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor, or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(tags_parameter, 'Tags') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Monitor', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py new file mode 100644 index 000000000000..47cc4820beb7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py @@ -0,0 +1,144 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Workloads/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.workloads.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists all the available API operations under this PR. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Workloads/operations"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py new file mode 100644 index 000000000000..37544a344b9d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py @@ -0,0 +1,620 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class ProviderInstancesOperations(object): + """ProviderInstancesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.workloads.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> Iterable["_models.ProviderInstanceListResult"]: + """Gets a list of provider instances in the specified SAP monitor. + + Gets a list of provider instances in the specified SAP monitor. The operations returns various + properties of each provider instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProviderInstanceListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.ProviderInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProviderInstanceListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any + ) -> "_models.ProviderInstance": + """Gets properties of a provider instance. + + Gets properties of a provider instance for the specified subscription, resource group, Monitor + name, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. + :type provider_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProviderInstance, or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.ProviderInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ProviderInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + + def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: "_models.ProviderInstance", + **kwargs: Any + ) -> "_models.ProviderInstance": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(provider_instance_parameter, 'ProviderInstance') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ProviderInstance', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ProviderInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: "_models.ProviderInstance", + **kwargs: Any + ) -> LROPoller["_models.ProviderInstance"]: + """Creates a provider instance. + + Creates a provider instance for the specified subscription, resource group, Monitor name, and + resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. + :type provider_instance_name: str + :param provider_instance_parameter: Request body representing a provider instance. + :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance + :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 ProviderInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.ProviderInstance] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + 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_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + provider_instance_parameter=provider_instance_parameter, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ProviderInstance', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any + ) -> Optional["_models.OperationStatusResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + **kwargs: Any + ) -> LROPoller["_models.OperationStatusResult"]: + """Deletes a provider instance. + + Deletes a provider instance for the specified subscription, resource group, Monitor name, and + resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. + :type provider_instance_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 OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + provider_instance_name=provider_instance_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OperationStatusResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/py.typed b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloads/sdk_packaging.toml b/sdk/workloads/azure-mgmt-workloads/sdk_packaging.toml new file mode 100644 index 000000000000..e0654ca1938b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-workloads" +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/workloads/azure-mgmt-workloads/setup.py b/sdk/workloads/azure-mgmt-workloads/setup.py new file mode 100644 index 000000000000..d5dbabf2a04e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/setup.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-workloads" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/workloads/ci.yml b/sdk/workloads/ci.yml new file mode 100644 index 000000000000..94b5fc091e01 --- /dev/null +++ b/sdk/workloads/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/workloads/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/workloads/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: workloads + Artifacts: + - name: azure-mgmt-workloads + safeName: azuremgmtworkloads