diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/CHANGELOG.md b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/CHANGELOG.md new file mode 100644 index 000000000000..da1cffb000c2 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (2024-03-18) + +* Initial Release diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/LICENSE b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/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-workloadssapvirtualinstance/MANIFEST.in b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/MANIFEST.in new file mode 100644 index 000000000000..5bc62aeacfde --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/MANIFEST.in @@ -0,0 +1,8 @@ +include _meta.json +recursive-include tests *.py *.json +recursive-include samples *.py *.md +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/workloadssapvirtualinstance/py.typed diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/README.md b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/README.md new file mode 100644 index 000000000000..dc0bf48d48e3 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/README.md @@ -0,0 +1,61 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Workloadssapvirtualinstance Management Client Library. +This package has been tested with Python 3.8+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_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_ + +## Getting started + +### Prerequisites + +- Python 3.8+ is required to use this package. +- [Azure subscription](https://azure.microsoft.com/free/) + +### Install the package + +```bash +pip install azure-mgmt-workloadssapvirtualinstance +pip install azure-identity +``` + +### Authentication + +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` for Azure client secret. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, client can be authenticated by following code: + +```python +from azure.identity import DefaultAzureCredential +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient +import os + +sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") +client = WorkloadsSapVirtualInstanceMgmtClient(credential=DefaultAzureCredential(), subscription_id=sub_id) +``` + +## Examples + +Code samples for this package can be found at: +- [Search Workloadssapvirtualinstance Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +## Troubleshooting + +## Next steps + +## 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. diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/_meta.json b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/_meta.json new file mode 100644 index 000000000000..0b2097722137 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "0cca8953ec713d8cc0e940c37e865d36b43d18f8", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.7", + "use": [ + "@autorest/python@6.13.7", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "readme": "specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/readme.md" +} \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/__init__.py new file mode 100644 index 000000000000..a16e7fa2daf5 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._workloads_sap_virtual_instance_mgmt_client import WorkloadsSapVirtualInstanceMgmtClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "WorkloadsSapVirtualInstanceMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_configuration.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_configuration.py new file mode 100644 index 000000000000..be01f7187ae4 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +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 WorkloadsSapVirtualInstanceMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for WorkloadsSapVirtualInstanceMgmtClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-10-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: + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-workloadssapvirtualinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_patch.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_serialization.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_serialization.py new file mode 100644 index 000000000000..2f781d740827 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_serialization.py @@ -0,0 +1,1998 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + else: + return date_obj diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_vendor.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_vendor.py new file mode 100644 index 000000000000..bde502c0bccf --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_vendor.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------- +# 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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import WorkloadsSapVirtualInstanceMgmtClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +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 + + +class WorkloadsSapVirtualInstanceMgmtClientMixinABC(ABC): # pylint: disable=name-too-long + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: WorkloadsSapVirtualInstanceMgmtClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_version.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_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-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_workloads_sap_virtual_instance_mgmt_client.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_workloads_sap_virtual_instance_mgmt_client.py new file mode 100644 index 000000000000..11ef1b380085 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/_workloads_sap_virtual_instance_mgmt_client.py @@ -0,0 +1,144 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy + +from . import models as _models +from ._configuration import WorkloadsSapVirtualInstanceMgmtClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + Operations, + SAPApplicationServerInstancesOperations, + SAPCentralInstancesOperations, + SAPDatabaseInstancesOperations, + SAPVirtualInstancesOperations, + WorkloadsSapVirtualInstanceMgmtClientOperationsMixin, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class WorkloadsSapVirtualInstanceMgmtClient( + WorkloadsSapVirtualInstanceMgmtClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword + """Workloads client provides access to various workload operations. + + :ivar sap_virtual_instances: SAPVirtualInstancesOperations operations + :vartype sap_virtual_instances: + azure.mgmt.workloadssapvirtualinstance.operations.SAPVirtualInstancesOperations + :ivar sap_central_instances: SAPCentralInstancesOperations operations + :vartype sap_central_instances: + azure.mgmt.workloadssapvirtualinstance.operations.SAPCentralInstancesOperations + :ivar sap_database_instances: SAPDatabaseInstancesOperations operations + :vartype sap_database_instances: + azure.mgmt.workloadssapvirtualinstance.operations.SAPDatabaseInstancesOperations + :ivar sap_application_server_instances: SAPApplicationServerInstancesOperations operations + :vartype sap_application_server_instances: + azure.mgmt.workloadssapvirtualinstance.operations.SAPApplicationServerInstancesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.workloadssapvirtualinstance.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-10-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 = WorkloadsSapVirtualInstanceMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.sap_virtual_instances = SAPVirtualInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sap_central_instances = SAPCentralInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sap_database_instances = SAPDatabaseInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sap_application_server_instances = SAPApplicationServerInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "WorkloadsSapVirtualInstanceMgmtClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/__init__.py new file mode 100644 index 000000000000..94dec8f809d6 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/__init__.py @@ -0,0 +1,23 @@ +# 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_sap_virtual_instance_mgmt_client import WorkloadsSapVirtualInstanceMgmtClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "WorkloadsSapVirtualInstanceMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_configuration.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_configuration.py new file mode 100644 index 000000000000..6f33f8ea4c10 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +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 WorkloadsSapVirtualInstanceMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for WorkloadsSapVirtualInstanceMgmtClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-10-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: + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-workloadssapvirtualinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_patch.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_vendor.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_vendor.py new file mode 100644 index 000000000000..35e7eba4ee78 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# 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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import WorkloadsSapVirtualInstanceMgmtClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class WorkloadsSapVirtualInstanceMgmtClientMixinABC(ABC): # pylint: disable=name-too-long + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: WorkloadsSapVirtualInstanceMgmtClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_workloads_sap_virtual_instance_mgmt_client.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_workloads_sap_virtual_instance_mgmt_client.py new file mode 100644 index 000000000000..02a52de8a2d7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/_workloads_sap_virtual_instance_mgmt_client.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy + +from .. import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import WorkloadsSapVirtualInstanceMgmtClientConfiguration +from .operations import ( + Operations, + SAPApplicationServerInstancesOperations, + SAPCentralInstancesOperations, + SAPDatabaseInstancesOperations, + SAPVirtualInstancesOperations, + WorkloadsSapVirtualInstanceMgmtClientOperationsMixin, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class WorkloadsSapVirtualInstanceMgmtClient( + WorkloadsSapVirtualInstanceMgmtClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword + """Workloads client provides access to various workload operations. + + :ivar sap_virtual_instances: SAPVirtualInstancesOperations operations + :vartype sap_virtual_instances: + azure.mgmt.workloadssapvirtualinstance.aio.operations.SAPVirtualInstancesOperations + :ivar sap_central_instances: SAPCentralInstancesOperations operations + :vartype sap_central_instances: + azure.mgmt.workloadssapvirtualinstance.aio.operations.SAPCentralInstancesOperations + :ivar sap_database_instances: SAPDatabaseInstancesOperations operations + :vartype sap_database_instances: + azure.mgmt.workloadssapvirtualinstance.aio.operations.SAPDatabaseInstancesOperations + :ivar sap_application_server_instances: SAPApplicationServerInstancesOperations operations + :vartype sap_application_server_instances: + azure.mgmt.workloadssapvirtualinstance.aio.operations.SAPApplicationServerInstancesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.workloadssapvirtualinstance.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-10-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 = WorkloadsSapVirtualInstanceMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.sap_virtual_instances = SAPVirtualInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sap_central_instances = SAPCentralInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sap_database_instances = SAPDatabaseInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sap_application_server_instances = SAPApplicationServerInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "WorkloadsSapVirtualInstanceMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/__init__.py new file mode 100644 index 000000000000..b5dcb87baf6c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._workloads_sap_virtual_instance_mgmt_client_operations import WorkloadsSapVirtualInstanceMgmtClientOperationsMixin +from ._sap_virtual_instances_operations import SAPVirtualInstancesOperations +from ._sap_central_instances_operations import SAPCentralInstancesOperations +from ._sap_database_instances_operations import SAPDatabaseInstancesOperations +from ._sap_application_server_instances_operations import SAPApplicationServerInstancesOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "WorkloadsSapVirtualInstanceMgmtClientOperationsMixin", + "SAPVirtualInstancesOperations", + "SAPCentralInstancesOperations", + "SAPDatabaseInstancesOperations", + "SAPApplicationServerInstancesOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_operations.py new file mode 100644 index 000000000000..89eda586f6a2 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_operations.py @@ -0,0 +1,131 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.aio.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_patch.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_application_server_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_application_server_instances_operations.py new file mode 100644 index 000000000000..2b57626e2703 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_application_server_instances_operations.py @@ -0,0 +1,1148 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._sap_application_server_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_start_instance_request, + build_stop_instance_request, + build_update_request, +) +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SAPApplicationServerInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.aio.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_application_server_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Gets the SAP Application Server Instance corresponding to the Virtual Instance for SAP + solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPApplicationServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.SAPApplicationServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPApplicationServerInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.SAPApplicationServerInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server Instance resource. :code:`
`:code:`
`This will be used by + service only. PUT by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server Instance resource. :code:`
`:code:`
`This will be used by + service only. PUT by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.SAPApplicationServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server Instance resource. :code:`
`:code:`
`This will be used by + service only. PUT by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Is either a + SAPApplicationServerInstance type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SAPApplicationServerInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SAPApplicationServerInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.UpdateSAPApplicationInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Updates the SAP Application server instance resource. This can be used to update tags on the + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPApplicationInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Updates the SAP Application server instance resource. This can be used to update tags on the + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.UpdateSAPApplicationInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Updates the SAP Application server instance resource. This can be used to update tags on the + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Is either a + UpdateSAPApplicationInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPApplicationInstanceRequest + or IO[bytes] + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPApplicationInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPApplicationServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the SAP Application Server Instance resource. :code:`
`:code:`
`This operation + will be used by service only. Delete by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SAPApplicationServerInstance"]: + """Lists the SAP Application Server Instance resources for a given Virtual Instance for SAP + solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An iterator like instance of either SAPApplicationServerInstance or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPApplicationServerInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SAPApplicationServerInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + async def _start_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance start request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance start request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance start request body. Is either a StartRequest type + or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _stop_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance stop request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance stop request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance stop request body. Is either a StopRequest type or + a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_central_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_central_instances_operations.py new file mode 100644 index 000000000000..30e46f71c840 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_central_instances_operations.py @@ -0,0 +1,1149 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._sap_central_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_start_instance_request, + build_stop_instance_request, + build_update_request, +) +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SAPCentralInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.aio.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_central_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Gets the SAP Central Services Instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPCentralServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.SAPCentralServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPCentralServerInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.SAPCentralServerInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPCentralServerInstance]: + """Creates the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. PUT operation on this resource by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPCentralServerInstance]: + """Creates the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. PUT operation on this resource by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.SAPCentralServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPCentralServerInstance]: + """Creates the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. PUT operation on this resource by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance request body. Is either a + SAPCentralServerInstance type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SAPCentralServerInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SAPCentralServerInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.UpdateSAPCentralInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Updates the SAP Central Services Instance resource. :code:`
`:code:`
`This can be used to + update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPCentralInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Updates the SAP Central Services Instance resource. :code:`
`:code:`
`This can be used to + update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.UpdateSAPCentralInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Updates the SAP Central Services Instance resource. :code:`
`:code:`
`This can be used to + update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance resource request body. Is either a + UpdateSAPCentralInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPCentralInstanceRequest or + IO[bytes] + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPCentralInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPCentralServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. Delete operation on this resource by end user will return a Bad Request error. + You can delete the parent resource, which is the Virtual Instance for SAP solutions resource, + using the delete operation on it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SAPCentralServerInstance"]: + """Lists the SAP Central Services Instance resource for the given Virtual Instance for SAP + solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An iterator like instance of either SAPCentralServerInstance or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPCentralInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SAPCentralInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + async def _start_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance start request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance start request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance start request body. Is either a StartRequest type or + a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _stop_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance stop request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance stop request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance stop request body. Is either a StopRequest type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_database_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_database_instances_operations.py new file mode 100644 index 000000000000..6b6465aafb50 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_database_instances_operations.py @@ -0,0 +1,1145 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._sap_database_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_start_instance_request, + build_stop_instance_request, + build_update_request, +) +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SAPDatabaseInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.aio.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_database_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Gets the SAP Database Instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPDatabaseInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.SAPDatabaseInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPDatabaseInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.SAPDatabaseInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPDatabaseInstance]: + """Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. PUT by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Request body of Database resource of a SAP system. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPDatabaseInstance]: + """Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. PUT by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Request body of Database resource of a SAP system. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.SAPDatabaseInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPDatabaseInstance]: + """Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. PUT by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Request body of Database resource of a SAP system. Is either a SAPDatabaseInstance + type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SAPDatabaseInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SAPDatabaseInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.UpdateSAPDatabaseInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Updates the Database instance resource. This can be used to update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Database resource update request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPDatabaseInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Updates the Database instance resource. This can be used to update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Database resource update request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.UpdateSAPDatabaseInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Updates the Database instance resource. This can be used to update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Database resource update request body. Is either a + UpdateSAPDatabaseInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPDatabaseInstanceRequest or + IO[bytes] + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPDatabaseInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPDatabaseInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. Delete by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SAPDatabaseInstance"]: + """Lists the Database resources associated with a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An iterator like instance of either SAPDatabaseInstance or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPDatabaseInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SAPDatabaseInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + async def _start_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: SAP Database server instance start request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: SAP Database server instance start request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: SAP Database server instance start request body. Is either a StartRequest type or + a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _stop_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Stop request for the database instance of the SAP system. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Stop request for the database instance of the SAP system. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Stop request for the database instance of the SAP system. Is either a StopRequest + type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_virtual_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_virtual_instances_operations.py new file mode 100644 index 000000000000..4627975cfc1f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_sap_virtual_instances_operations.py @@ -0,0 +1,1226 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._sap_virtual_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_start_request, + build_stop_request, + build_update_request, +) +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SAPVirtualInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.aio.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_virtual_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.SAPVirtualInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPVirtualInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPVirtualInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.SAPVirtualInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPVirtualInstance]: + """Creates a Virtual Instance for SAP solutions (VIS) resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Virtual Instance for SAP solutions resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPVirtualInstance]: + """Creates a Virtual Instance for SAP solutions (VIS) resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Virtual Instance for SAP solutions resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.SAPVirtualInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPVirtualInstance]: + """Creates a Virtual Instance for SAP solutions (VIS) resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Virtual Instance for SAP solutions resource request body. Is either a + SAPVirtualInstance type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SAPVirtualInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SAPVirtualInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> _models.SAPVirtualInstance: + """Gets a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPVirtualInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.UpdateSAPVirtualInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPVirtualInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPVirtualInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.UpdateSAPVirtualInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPVirtualInstance]: + """Updates a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Request body to update a Virtual Instance for SAP solutions resource. Default + value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPVirtualInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPVirtualInstance]: + """Updates a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Request body to update a Virtual Instance for SAP solutions resource. Default + value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.UpdateSAPVirtualInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPVirtualInstance]: + """Updates a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Request body to update a Virtual Instance for SAP solutions resource. Is either a + UpdateSAPVirtualInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPVirtualInstanceRequest or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SAPVirtualInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SAPVirtualInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Virtual Instance for SAP solutions resource and its child resources, that is the + associated Central Services Instance, Application Server Instances and Database Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SAPVirtualInstance"]: + """Gets all Virtual Instances for SAP solutions resources in a Resource Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPVirtualInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SAPVirtualInstance"]: + """Gets all Virtual Instances for SAP solutions resources in a Subscription. + + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPVirtualInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + async def _start_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_start( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP application, that is the Central Services instance and Application server + instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource start request body. Default value + is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP application, that is the Central Services instance and Application server + instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource start request body. Default value + is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_start( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Starts the SAP application, that is the Central Services instance and Application server + instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource start request body. Is either a + StartRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _stop_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Application, that is the Application server instances and Central Services + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource stop request body. Default value + is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Application, that is the Application server instances and Central Services + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource stop request body. Default value + is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Stops the SAP Application, that is the Application server instances and Central Services + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource stop request body. Is either a + StopRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_workloads_sap_virtual_instance_mgmt_client_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_workloads_sap_virtual_instance_mgmt_client_operations.py new file mode 100644 index 000000000000..2d80b0de9605 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/aio/operations/_workloads_sap_virtual_instance_mgmt_client_operations.py @@ -0,0 +1,544 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._workloads_sap_virtual_instance_mgmt_client_operations import ( + build_sap_availability_zone_details_request, + build_sap_disk_configurations_request, + build_sap_sizing_recommendations_request, + build_sap_supported_sku_request, +) +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkloadsSapVirtualInstanceMgmtClientOperationsMixin( # pylint: disable=name-too-long + WorkloadsSapVirtualInstanceMgmtClientMixinABC +): + @overload + async def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[_models.SAPSizingRecommendationRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Default value is + None. + :type sap_sizing_recommendation: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Default value is + None. + :type sap_sizing_recommendation: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[Union[_models.SAPSizingRecommendationRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Is either a + SAPSizingRecommendationRequest type or a IO[bytes] type. Default value is None. + :type sap_sizing_recommendation: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationRequest or IO[bytes] + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPSizingRecommendationResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_sizing_recommendation, (IOBase, bytes)): + _content = sap_sizing_recommendation + else: + if sap_sizing_recommendation is not None: + _json = self._serialize.body(sap_sizing_recommendation, "SAPSizingRecommendationRequest") + else: + _json = None + + _request = build_sap_sizing_recommendations_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **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("SAPSizingRecommendationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[_models.SAPSupportedSkusRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Default value is None. + :type sap_supported_sku: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedSkusRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Default value is None. + :type sap_supported_sku: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[Union[_models.SAPSupportedSkusRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Is either a SAPSupportedSkusRequest + type or a IO[bytes] type. Default value is None. + :type sap_supported_sku: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedSkusRequest + or IO[bytes] + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPSupportedResourceSkusResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_supported_sku, (IOBase, bytes)): + _content = sap_supported_sku + else: + if sap_supported_sku is not None: + _json = self._serialize.body(sap_supported_sku, "SAPSupportedSkusRequest") + else: + _json = None + + _request = build_sap_supported_sku_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **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("SAPSupportedResourceSkusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[_models.SAPDiskConfigurationsRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Default value is None. + :type sap_disk_configurations: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Default value is None. + :type sap_disk_configurations: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[Union[_models.SAPDiskConfigurationsRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Is either a + SAPDiskConfigurationsRequest type or a IO[bytes] type. Default value is None. + :type sap_disk_configurations: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsRequest or IO[bytes] + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDiskConfigurationsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_disk_configurations, (IOBase, bytes)): + _content = sap_disk_configurations + else: + if sap_disk_configurations is not None: + _json = self._serialize.body(sap_disk_configurations, "SAPDiskConfigurationsRequest") + else: + _json = None + + _request = build_sap_disk_configurations_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **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("SAPDiskConfigurationsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[_models.SAPAvailabilityZoneDetailsRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_availability_zone_details: SAP Availability Zone Details Request body. Default value + is None. + :type sap_availability_zone_details: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_availability_zone_details: SAP Availability Zone Details Request body. Default value + is None. + :type sap_availability_zone_details: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[Union[_models.SAPAvailabilityZoneDetailsRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_availability_zone_details: SAP Availability Zone Details Request body. Is either a + SAPAvailabilityZoneDetailsRequest type or a IO[bytes] type. Default value is None. + :type sap_availability_zone_details: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsRequest or IO[bytes] + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPAvailabilityZoneDetailsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_availability_zone_details, (IOBase, bytes)): + _content = sap_availability_zone_details + else: + if sap_availability_zone_details is not None: + _json = self._serialize.body(sap_availability_zone_details, "SAPAvailabilityZoneDetailsRequest") + else: + _json = None + + _request = build_sap_availability_zone_details_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **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("SAPAvailabilityZoneDetailsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/__init__.py new file mode 100644 index 000000000000..b12cc97d0ead --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/__init__.py @@ -0,0 +1,275 @@ +# 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 ApplicationServerConfiguration +from ._models_py3 import ApplicationServerFullResourceNames +from ._models_py3 import ApplicationServerVmDetails +from ._models_py3 import CentralServerConfiguration +from ._models_py3 import CentralServerFullResourceNames +from ._models_py3 import CentralServerVmDetails +from ._models_py3 import CreateAndMountFileShareConfiguration +from ._models_py3 import DatabaseConfiguration +from ._models_py3 import DatabaseServerFullResourceNames +from ._models_py3 import DatabaseVmDetails +from ._models_py3 import DeployerVmPackages +from ._models_py3 import DeploymentConfiguration +from ._models_py3 import DeploymentWithOSConfiguration +from ._models_py3 import DiscoveryConfiguration +from ._models_py3 import DiskConfiguration +from ._models_py3 import DiskDetails +from ._models_py3 import DiskSku +from ._models_py3 import DiskVolumeConfiguration +from ._models_py3 import EnqueueReplicationServerProperties +from ._models_py3 import EnqueueServerProperties +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExternalInstallationSoftwareConfiguration +from ._models_py3 import FileShareConfiguration +from ._models_py3 import GatewayServerProperties +from ._models_py3 import HighAvailabilityConfiguration +from ._models_py3 import HighAvailabilitySoftwareConfiguration +from ._models_py3 import ImageReference +from ._models_py3 import InfrastructureConfiguration +from ._models_py3 import LinuxConfiguration +from ._models_py3 import LoadBalancerDetails +from ._models_py3 import LoadBalancerResourceNames +from ._models_py3 import ManagedRGConfiguration +from ._models_py3 import MessageServerProperties +from ._models_py3 import MountFileShareConfiguration +from ._models_py3 import NetworkConfiguration +from ._models_py3 import NetworkInterfaceResourceNames +from ._models_py3 import OSConfiguration +from ._models_py3 import OSProfile +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationStatusResult +from ._models_py3 import OsSapConfiguration +from ._models_py3 import Resource +from ._models_py3 import SAPApplicationServerInstance +from ._models_py3 import SAPApplicationServerInstanceList +from ._models_py3 import SAPApplicationServerProperties +from ._models_py3 import SAPAvailabilityZoneDetailsRequest +from ._models_py3 import SAPAvailabilityZoneDetailsResult +from ._models_py3 import SAPAvailabilityZonePair +from ._models_py3 import SAPCentralInstanceList +from ._models_py3 import SAPCentralServerInstance +from ._models_py3 import SAPCentralServerProperties +from ._models_py3 import SAPConfiguration +from ._models_py3 import SAPDatabaseInstance +from ._models_py3 import SAPDatabaseInstanceList +from ._models_py3 import SAPDatabaseProperties +from ._models_py3 import SAPDiskConfiguration +from ._models_py3 import SAPDiskConfigurationsRequest +from ._models_py3 import SAPDiskConfigurationsResult +from ._models_py3 import SAPInstallWithoutOSConfigSoftwareConfiguration +from ._models_py3 import SAPSizingRecommendationRequest +from ._models_py3 import SAPSizingRecommendationResult +from ._models_py3 import SAPSupportedResourceSkusResult +from ._models_py3 import SAPSupportedSku +from ._models_py3 import SAPSupportedSkusRequest +from ._models_py3 import SAPVirtualInstance +from ._models_py3 import SAPVirtualInstanceError +from ._models_py3 import SAPVirtualInstanceList +from ._models_py3 import SAPVirtualInstanceProperties +from ._models_py3 import ServiceInitiatedSoftwareConfiguration +from ._models_py3 import SharedStorageResourceNames +from ._models_py3 import SingleServerConfiguration +from ._models_py3 import SingleServerCustomResourceNames +from ._models_py3 import SingleServerFullResourceNames +from ._models_py3 import SingleServerRecommendationResult +from ._models_py3 import SkipFileShareConfiguration +from ._models_py3 import SoftwareConfiguration +from ._models_py3 import SshConfiguration +from ._models_py3 import SshKeyPair +from ._models_py3 import SshPublicKey +from ._models_py3 import StartRequest +from ._models_py3 import StopRequest +from ._models_py3 import StorageConfiguration +from ._models_py3 import StorageInformation +from ._models_py3 import SystemData +from ._models_py3 import ThreeTierConfiguration +from ._models_py3 import ThreeTierCustomResourceNames +from ._models_py3 import ThreeTierFullResourceNames +from ._models_py3 import ThreeTierRecommendationResult +from ._models_py3 import TrackedResource +from ._models_py3 import UpdateSAPApplicationInstanceRequest +from ._models_py3 import UpdateSAPCentralInstanceRequest +from ._models_py3 import UpdateSAPDatabaseInstanceRequest +from ._models_py3 import UpdateSAPVirtualInstanceProperties +from ._models_py3 import UpdateSAPVirtualInstanceRequest +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import UserAssignedServiceIdentity +from ._models_py3 import VirtualMachineConfiguration +from ._models_py3 import VirtualMachineResourceNames +from ._models_py3 import WindowsConfiguration + +from ._workloads_sap_virtual_instance_mgmt_client_enums import ActionType +from ._workloads_sap_virtual_instance_mgmt_client_enums import ApplicationServerVirtualMachineType +from ._workloads_sap_virtual_instance_mgmt_client_enums import CentralServerVirtualMachineType +from ._workloads_sap_virtual_instance_mgmt_client_enums import ConfigurationType +from ._workloads_sap_virtual_instance_mgmt_client_enums import CreatedByType +from ._workloads_sap_virtual_instance_mgmt_client_enums import DiskSkuName +from ._workloads_sap_virtual_instance_mgmt_client_enums import EnqueueReplicationServerType +from ._workloads_sap_virtual_instance_mgmt_client_enums import ManagedResourcesNetworkAccessType +from ._workloads_sap_virtual_instance_mgmt_client_enums import ManagedServiceIdentityType +from ._workloads_sap_virtual_instance_mgmt_client_enums import NamingPatternType +from ._workloads_sap_virtual_instance_mgmt_client_enums import OSType +from ._workloads_sap_virtual_instance_mgmt_client_enums import Origin +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPConfigurationType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPDatabaseScaleMethod +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPDatabaseType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPDeploymentType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPEnvironmentType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPHealthState +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPHighAvailabilityType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPProductType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPSoftwareInstallationType +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPVirtualInstanceState +from ._workloads_sap_virtual_instance_mgmt_client_enums import SAPVirtualInstanceStatus +from ._workloads_sap_virtual_instance_mgmt_client_enums import SapVirtualInstanceProvisioningState +from ._workloads_sap_virtual_instance_mgmt_client_enums import Versions +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ApplicationServerConfiguration", + "ApplicationServerFullResourceNames", + "ApplicationServerVmDetails", + "CentralServerConfiguration", + "CentralServerFullResourceNames", + "CentralServerVmDetails", + "CreateAndMountFileShareConfiguration", + "DatabaseConfiguration", + "DatabaseServerFullResourceNames", + "DatabaseVmDetails", + "DeployerVmPackages", + "DeploymentConfiguration", + "DeploymentWithOSConfiguration", + "DiscoveryConfiguration", + "DiskConfiguration", + "DiskDetails", + "DiskSku", + "DiskVolumeConfiguration", + "EnqueueReplicationServerProperties", + "EnqueueServerProperties", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDetail", + "ErrorResponse", + "ExternalInstallationSoftwareConfiguration", + "FileShareConfiguration", + "GatewayServerProperties", + "HighAvailabilityConfiguration", + "HighAvailabilitySoftwareConfiguration", + "ImageReference", + "InfrastructureConfiguration", + "LinuxConfiguration", + "LoadBalancerDetails", + "LoadBalancerResourceNames", + "ManagedRGConfiguration", + "MessageServerProperties", + "MountFileShareConfiguration", + "NetworkConfiguration", + "NetworkInterfaceResourceNames", + "OSConfiguration", + "OSProfile", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationStatusResult", + "OsSapConfiguration", + "Resource", + "SAPApplicationServerInstance", + "SAPApplicationServerInstanceList", + "SAPApplicationServerProperties", + "SAPAvailabilityZoneDetailsRequest", + "SAPAvailabilityZoneDetailsResult", + "SAPAvailabilityZonePair", + "SAPCentralInstanceList", + "SAPCentralServerInstance", + "SAPCentralServerProperties", + "SAPConfiguration", + "SAPDatabaseInstance", + "SAPDatabaseInstanceList", + "SAPDatabaseProperties", + "SAPDiskConfiguration", + "SAPDiskConfigurationsRequest", + "SAPDiskConfigurationsResult", + "SAPInstallWithoutOSConfigSoftwareConfiguration", + "SAPSizingRecommendationRequest", + "SAPSizingRecommendationResult", + "SAPSupportedResourceSkusResult", + "SAPSupportedSku", + "SAPSupportedSkusRequest", + "SAPVirtualInstance", + "SAPVirtualInstanceError", + "SAPVirtualInstanceList", + "SAPVirtualInstanceProperties", + "ServiceInitiatedSoftwareConfiguration", + "SharedStorageResourceNames", + "SingleServerConfiguration", + "SingleServerCustomResourceNames", + "SingleServerFullResourceNames", + "SingleServerRecommendationResult", + "SkipFileShareConfiguration", + "SoftwareConfiguration", + "SshConfiguration", + "SshKeyPair", + "SshPublicKey", + "StartRequest", + "StopRequest", + "StorageConfiguration", + "StorageInformation", + "SystemData", + "ThreeTierConfiguration", + "ThreeTierCustomResourceNames", + "ThreeTierFullResourceNames", + "ThreeTierRecommendationResult", + "TrackedResource", + "UpdateSAPApplicationInstanceRequest", + "UpdateSAPCentralInstanceRequest", + "UpdateSAPDatabaseInstanceRequest", + "UpdateSAPVirtualInstanceProperties", + "UpdateSAPVirtualInstanceRequest", + "UserAssignedIdentity", + "UserAssignedServiceIdentity", + "VirtualMachineConfiguration", + "VirtualMachineResourceNames", + "WindowsConfiguration", + "ActionType", + "ApplicationServerVirtualMachineType", + "CentralServerVirtualMachineType", + "ConfigurationType", + "CreatedByType", + "DiskSkuName", + "EnqueueReplicationServerType", + "ManagedResourcesNetworkAccessType", + "ManagedServiceIdentityType", + "NamingPatternType", + "OSType", + "Origin", + "SAPConfigurationType", + "SAPDatabaseScaleMethod", + "SAPDatabaseType", + "SAPDeploymentType", + "SAPEnvironmentType", + "SAPHealthState", + "SAPHighAvailabilityType", + "SAPProductType", + "SAPSoftwareInstallationType", + "SAPVirtualInstanceState", + "SAPVirtualInstanceStatus", + "SapVirtualInstanceProvisioningState", + "Versions", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_models_py3.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_models_py3.py new file mode 100644 index 000000000000..48059fde2579 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_models_py3.py @@ -0,0 +1,4855 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ApplicationServerConfiguration(_serialization.Model): + """Gets or sets the application server configuration. + + All required parameters must be populated in order to send to server. + + :ivar subnet_id: The subnet id. Required. + :vartype subnet_id: str + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. + :vartype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :ivar instance_count: The number of app server instances. Required. + :vartype instance_count: int + """ + + _validation = { + "subnet_id": {"required": True}, + "virtual_machine_configuration": {"required": True}, + "instance_count": {"required": True}, + } + + _attribute_map = { + "subnet_id": {"key": "subnetId", "type": "str"}, + "virtual_machine_configuration": {"key": "virtualMachineConfiguration", "type": "VirtualMachineConfiguration"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__( + self, + *, + subnet_id: str, + virtual_machine_configuration: "_models.VirtualMachineConfiguration", + instance_count: int, + **kwargs: Any + ) -> None: + """ + :keyword subnet_id: The subnet id. Required. + :paramtype subnet_id: str + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. + :paramtype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :keyword instance_count: The number of app server instances. Required. + :paramtype instance_count: int + """ + super().__init__(**kwargs) + self.subnet_id = subnet_id + self.virtual_machine_configuration = virtual_machine_configuration + self.instance_count = instance_count + + +class ApplicationServerFullResourceNames(_serialization.Model): + """The full resource names object for application layer resources. The number of entries in this + list should be equal to the number VMs to be created for application layer. + + :ivar virtual_machines: The list of virtual machine naming details. + :vartype virtual_machines: + list[~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames] + :ivar availability_set_name: The full name for availability set. In case name is not provided, + it will be defaulted to {SID}-App-AvSet. + :vartype availability_set_name: str + """ + + _attribute_map = { + "virtual_machines": {"key": "virtualMachines", "type": "[VirtualMachineResourceNames]"}, + "availability_set_name": {"key": "availabilitySetName", "type": "str"}, + } + + def __init__( + self, + *, + virtual_machines: Optional[List["_models.VirtualMachineResourceNames"]] = None, + availability_set_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword virtual_machines: The list of virtual machine naming details. + :paramtype virtual_machines: + list[~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames] + :keyword availability_set_name: The full name for availability set. In case name is not + provided, it will be defaulted to {SID}-App-AvSet. + :paramtype availability_set_name: str + """ + super().__init__(**kwargs) + self.virtual_machines = virtual_machines + self.availability_set_name = availability_set_name + + +class ApplicationServerVmDetails(_serialization.Model): + """The Application Server VM Details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Defines the type of application server VM. Known values are: "Active", "Standby", + and "Unknown". + :vartype type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ApplicationServerVirtualMachineType + :ivar virtual_machine_id: + :vartype virtual_machine_id: str + :ivar storage_details: Storage details of all the Storage Accounts attached to the App Virtual + Machine. For e.g. NFS on AFS Shared Storage. + :vartype storage_details: + list[~azure.mgmt.workloadssapvirtualinstance.models.StorageInformation] + """ + + _validation = { + "type": {"readonly": True}, + "virtual_machine_id": {"readonly": True}, + "storage_details": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, + "storage_details": {"key": "storageDetails", "type": "[StorageInformation]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.virtual_machine_id = None + self.storage_details = None + + +class CentralServerConfiguration(_serialization.Model): + """Gets or sets the central server configuration. + + All required parameters must be populated in order to send to server. + + :ivar subnet_id: The subnet id. Required. + :vartype subnet_id: str + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. + :vartype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :ivar instance_count: The number of central server VMs. Required. + :vartype instance_count: int + """ + + _validation = { + "subnet_id": {"required": True}, + "virtual_machine_configuration": {"required": True}, + "instance_count": {"required": True}, + } + + _attribute_map = { + "subnet_id": {"key": "subnetId", "type": "str"}, + "virtual_machine_configuration": {"key": "virtualMachineConfiguration", "type": "VirtualMachineConfiguration"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + } + + def __init__( + self, + *, + subnet_id: str, + virtual_machine_configuration: "_models.VirtualMachineConfiguration", + instance_count: int, + **kwargs: Any + ) -> None: + """ + :keyword subnet_id: The subnet id. Required. + :paramtype subnet_id: str + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. + :paramtype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :keyword instance_count: The number of central server VMs. Required. + :paramtype instance_count: int + """ + super().__init__(**kwargs) + self.subnet_id = subnet_id + self.virtual_machine_configuration = virtual_machine_configuration + self.instance_count = instance_count + + +class CentralServerFullResourceNames(_serialization.Model): + """The full resource names object for central server layer resources. + + :ivar virtual_machines: The list of names for all ASCS virtual machines to be deployed. The + number of entries in this list should be equal to the number VMs to be created for ASCS layer. + At maximum, there can be two virtual machines at this layer: ASCS and ERS. + :vartype virtual_machines: + list[~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames] + :ivar availability_set_name: The full name for availability set. In case name is not provided, + it will be defaulted to {SID}-ASCS-AvSet. + :vartype availability_set_name: str + :ivar load_balancer: The resource names object for load balancer and related resources. + :vartype load_balancer: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerResourceNames + """ + + _validation = { + "virtual_machines": {"max_items": 2, "min_items": 0}, + } + + _attribute_map = { + "virtual_machines": {"key": "virtualMachines", "type": "[VirtualMachineResourceNames]"}, + "availability_set_name": {"key": "availabilitySetName", "type": "str"}, + "load_balancer": {"key": "loadBalancer", "type": "LoadBalancerResourceNames"}, + } + + def __init__( + self, + *, + virtual_machines: Optional[List["_models.VirtualMachineResourceNames"]] = None, + availability_set_name: Optional[str] = None, + load_balancer: Optional["_models.LoadBalancerResourceNames"] = None, + **kwargs: Any + ) -> None: + """ + :keyword virtual_machines: The list of names for all ASCS virtual machines to be deployed. The + number of entries in this list should be equal to the number VMs to be created for ASCS layer. + At maximum, there can be two virtual machines at this layer: ASCS and ERS. + :paramtype virtual_machines: + list[~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames] + :keyword availability_set_name: The full name for availability set. In case name is not + provided, it will be defaulted to {SID}-ASCS-AvSet. + :paramtype availability_set_name: str + :keyword load_balancer: The resource names object for load balancer and related resources. + :paramtype load_balancer: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerResourceNames + """ + super().__init__(**kwargs) + self.virtual_machines = virtual_machines + self.availability_set_name = availability_set_name + self.load_balancer = load_balancer + + +class CentralServerVmDetails(_serialization.Model): + """The SAP Central Services Instance VM details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Defines the type of central server VM. Known values are: "Primary", "Secondary", + "Unknown", "ASCS", "ERSInactive", "ERS", and "Standby". + :vartype type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.CentralServerVirtualMachineType + :ivar virtual_machine_id: + :vartype virtual_machine_id: str + :ivar storage_details: Storage details of all the Storage Accounts attached to the ASCS Virtual + Machine. For e.g. NFS on AFS Shared Storage. + :vartype storage_details: + list[~azure.mgmt.workloadssapvirtualinstance.models.StorageInformation] + """ + + _validation = { + "type": {"readonly": True}, + "virtual_machine_id": {"readonly": True}, + "storage_details": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, + "storage_details": {"key": "storageDetails", "type": "[StorageInformation]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.virtual_machine_id = None + self.storage_details = None + + +class FileShareConfiguration(_serialization.Model): + """File Share configuration details, populated with information on storage configuration mounted + on the VIS. The createAndMount option is selected in case of missing input. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CreateAndMountFileShareConfiguration, MountFileShareConfiguration, SkipFileShareConfiguration + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The type of file share config. Required. Known values are: "Skip", + "CreateAndMount", and "Mount". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ConfigurationType + """ + + _validation = { + "configuration_type": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + } + + _subtype_map = { + "configuration_type": { + "CreateAndMount": "CreateAndMountFileShareConfiguration", + "Mount": "MountFileShareConfiguration", + "Skip": "SkipFileShareConfiguration", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.configuration_type: Optional[str] = None + + +class CreateAndMountFileShareConfiguration(FileShareConfiguration): + """Gets or sets the file share configuration where the transport directory fileshare is created + and mounted as a part of the create infra flow. Please pre-create the resource group you intend + to place the transport directory in. The storage account and fileshare will be auto-created by + the ACSS and doesn't need to be pre-created. + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The type of file share config. Required. Known values are: "Skip", + "CreateAndMount", and "Mount". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ConfigurationType + :ivar resource_group: The name of transport file share resource group. This should be pre + created by the customer. The app rg is used in case of missing input. + :vartype resource_group: str + :ivar storage_account_name: The name of file share storage account name . A custom name is used + in case of missing input. + :vartype storage_account_name: str + """ + + _validation = { + "configuration_type": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "storage_account_name": {"key": "storageAccountName", "type": "str"}, + } + + def __init__( + self, *, resource_group: Optional[str] = None, storage_account_name: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword resource_group: The name of transport file share resource group. This should be pre + created by the customer. The app rg is used in case of missing input. + :paramtype resource_group: str + :keyword storage_account_name: The name of file share storage account name . A custom name is + used in case of missing input. + :paramtype storage_account_name: str + """ + super().__init__(**kwargs) + self.configuration_type: str = "CreateAndMount" + self.resource_group = resource_group + self.storage_account_name = storage_account_name + + +class DatabaseConfiguration(_serialization.Model): + """Gets or sets the database configuration. + + All required parameters must be populated in order to send to server. + + :ivar database_type: The database type. Known values are: "HANA" and "DB2". + :vartype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :ivar subnet_id: The subnet id. Required. + :vartype subnet_id: str + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. + :vartype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :ivar instance_count: The number of database VMs. Required. + :vartype instance_count: int + :ivar disk_configuration: Gets or sets the disk configuration. + :vartype disk_configuration: ~azure.mgmt.workloadssapvirtualinstance.models.DiskConfiguration + """ + + _validation = { + "subnet_id": {"required": True}, + "virtual_machine_configuration": {"required": True}, + "instance_count": {"required": True}, + } + + _attribute_map = { + "database_type": {"key": "databaseType", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "virtual_machine_configuration": {"key": "virtualMachineConfiguration", "type": "VirtualMachineConfiguration"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + "disk_configuration": {"key": "diskConfiguration", "type": "DiskConfiguration"}, + } + + def __init__( + self, + *, + subnet_id: str, + virtual_machine_configuration: "_models.VirtualMachineConfiguration", + instance_count: int, + database_type: Optional[Union[str, "_models.SAPDatabaseType"]] = None, + disk_configuration: Optional["_models.DiskConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword database_type: The database type. Known values are: "HANA" and "DB2". + :paramtype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :keyword subnet_id: The subnet id. Required. + :paramtype subnet_id: str + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. + :paramtype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :keyword instance_count: The number of database VMs. Required. + :paramtype instance_count: int + :keyword disk_configuration: Gets or sets the disk configuration. + :paramtype disk_configuration: ~azure.mgmt.workloadssapvirtualinstance.models.DiskConfiguration + """ + super().__init__(**kwargs) + self.database_type = database_type + self.subnet_id = subnet_id + self.virtual_machine_configuration = virtual_machine_configuration + self.instance_count = instance_count + self.disk_configuration = disk_configuration + + +class DatabaseServerFullResourceNames(_serialization.Model): + """The full resource names object for database layer resources. The number of entries in this list + should be equal to the number VMs to be created for database layer. + + :ivar virtual_machines: The list of virtual machine naming details. + :vartype virtual_machines: + list[~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames] + :ivar availability_set_name: The full name for availability set. In case name is not provided, + it will be defaulted to {SID}-DB-AvSet. + :vartype availability_set_name: str + :ivar load_balancer: The resource names object for load balancer and related resources. + :vartype load_balancer: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerResourceNames + """ + + _validation = { + "virtual_machines": {"max_items": 2, "min_items": 0}, + } + + _attribute_map = { + "virtual_machines": {"key": "virtualMachines", "type": "[VirtualMachineResourceNames]"}, + "availability_set_name": {"key": "availabilitySetName", "type": "str"}, + "load_balancer": {"key": "loadBalancer", "type": "LoadBalancerResourceNames"}, + } + + def __init__( + self, + *, + virtual_machines: Optional[List["_models.VirtualMachineResourceNames"]] = None, + availability_set_name: Optional[str] = None, + load_balancer: Optional["_models.LoadBalancerResourceNames"] = None, + **kwargs: Any + ) -> None: + """ + :keyword virtual_machines: The list of virtual machine naming details. + :paramtype virtual_machines: + list[~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames] + :keyword availability_set_name: The full name for availability set. In case name is not + provided, it will be defaulted to {SID}-DB-AvSet. + :paramtype availability_set_name: str + :keyword load_balancer: The resource names object for load balancer and related resources. + :paramtype load_balancer: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerResourceNames + """ + super().__init__(**kwargs) + self.virtual_machines = virtual_machines + self.availability_set_name = availability_set_name + self.load_balancer = load_balancer + + +class DatabaseVmDetails(_serialization.Model): + """Database VM details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar virtual_machine_id: + :vartype virtual_machine_id: str + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", "Unavailable", and "SoftShutdown". + :vartype status: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceStatus + :ivar storage_details: Storage details of all the Storage Accounts attached to the Database + Virtual Machine. For e.g. NFS on AFS Shared Storage. + :vartype storage_details: + list[~azure.mgmt.workloadssapvirtualinstance.models.StorageInformation] + """ + + _validation = { + "virtual_machine_id": {"readonly": True}, + "status": {"readonly": True}, + "storage_details": {"readonly": True}, + } + + _attribute_map = { + "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "storage_details": {"key": "storageDetails", "type": "[StorageInformation]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.virtual_machine_id = None + self.status = None + self.storage_details = None + + +class DeployerVmPackages(_serialization.Model): + """Defines the url and storage account ID where deployer VM packages are uploaded. + + :ivar url: The URL to the deployer VM packages file. + :vartype url: str + :ivar storage_account_id: The deployer VM packages storage account id. + :vartype storage_account_id: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, + } + + def __init__(self, *, url: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword url: The URL to the deployer VM packages file. + :paramtype url: str + :keyword storage_account_id: The deployer VM packages storage account id. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) + self.url = url + self.storage_account_id = storage_account_id + + +class SAPConfiguration(_serialization.Model): + """The SAP Configuration. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DeploymentConfiguration, DeploymentWithOSConfiguration, DiscoveryConfiguration + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPConfigurationType + """ + + _validation = { + "configuration_type": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + } + + _subtype_map = { + "configuration_type": { + "Deployment": "DeploymentConfiguration", + "DeploymentWithOSConfig": "DeploymentWithOSConfiguration", + "Discovery": "DiscoveryConfiguration", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.configuration_type: Optional[str] = None + + +class DeploymentConfiguration(SAPConfiguration): + """Deployment Configuration. + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPConfigurationType + :ivar app_location: The geo-location where the SAP system is to be created. + :vartype app_location: str + :ivar infrastructure_configuration: The infrastructure configuration. + :vartype infrastructure_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.InfrastructureConfiguration + :ivar software_configuration: The software configuration. + :vartype software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.SoftwareConfiguration + """ + + _validation = { + "configuration_type": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + "app_location": {"key": "appLocation", "type": "str"}, + "infrastructure_configuration": {"key": "infrastructureConfiguration", "type": "InfrastructureConfiguration"}, + "software_configuration": {"key": "softwareConfiguration", "type": "SoftwareConfiguration"}, + } + + def __init__( + self, + *, + app_location: Optional[str] = None, + infrastructure_configuration: Optional["_models.InfrastructureConfiguration"] = None, + software_configuration: Optional["_models.SoftwareConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword app_location: The geo-location where the SAP system is to be created. + :paramtype app_location: str + :keyword infrastructure_configuration: The infrastructure configuration. + :paramtype infrastructure_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.InfrastructureConfiguration + :keyword software_configuration: The software configuration. + :paramtype software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.SoftwareConfiguration + """ + super().__init__(**kwargs) + self.configuration_type: str = "Deployment" + self.app_location = app_location + self.infrastructure_configuration = infrastructure_configuration + self.software_configuration = software_configuration + + +class DeploymentWithOSConfiguration(SAPConfiguration): + """Deployment along with OS Configuration. + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPConfigurationType + :ivar app_location: The geo-location where the SAP system is to be created. + :vartype app_location: str + :ivar infrastructure_configuration: The infrastructure configuration. + :vartype infrastructure_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.InfrastructureConfiguration + :ivar software_configuration: The software configuration. + :vartype software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.SoftwareConfiguration + :ivar os_sap_configuration: The OS and SAP configuration. + :vartype os_sap_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.OsSapConfiguration + """ + + _validation = { + "configuration_type": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + "app_location": {"key": "appLocation", "type": "str"}, + "infrastructure_configuration": {"key": "infrastructureConfiguration", "type": "InfrastructureConfiguration"}, + "software_configuration": {"key": "softwareConfiguration", "type": "SoftwareConfiguration"}, + "os_sap_configuration": {"key": "osSapConfiguration", "type": "OsSapConfiguration"}, + } + + def __init__( + self, + *, + app_location: Optional[str] = None, + infrastructure_configuration: Optional["_models.InfrastructureConfiguration"] = None, + software_configuration: Optional["_models.SoftwareConfiguration"] = None, + os_sap_configuration: Optional["_models.OsSapConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword app_location: The geo-location where the SAP system is to be created. + :paramtype app_location: str + :keyword infrastructure_configuration: The infrastructure configuration. + :paramtype infrastructure_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.InfrastructureConfiguration + :keyword software_configuration: The software configuration. + :paramtype software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.SoftwareConfiguration + :keyword os_sap_configuration: The OS and SAP configuration. + :paramtype os_sap_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.OsSapConfiguration + """ + super().__init__(**kwargs) + self.configuration_type: str = "DeploymentWithOSConfig" + self.app_location = app_location + self.infrastructure_configuration = infrastructure_configuration + self.software_configuration = software_configuration + self.os_sap_configuration = os_sap_configuration + + +class DiscoveryConfiguration(SAPConfiguration): + """Discovery Details. + + 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 server. + + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPConfigurationType + :ivar central_server_vm_id: The virtual machine ID of the Central Server. + :vartype central_server_vm_id: str + :ivar managed_rg_storage_account_name: The custom storage account name for the storage account + created by the service in the managed resource group created as part of VIS + deployment.:code:`
`:code:`
`Refer to the storage account naming rules `here + `_.:code:`
`:code:`
`If # pylint: disable=line-too-long + not provided, the service will create the storage account with a random name. + :vartype managed_rg_storage_account_name: str + :ivar app_location: The geo-location where the SAP system exists. + :vartype app_location: str + """ + + _validation = { + "configuration_type": {"required": True}, + "managed_rg_storage_account_name": {"max_length": 24, "min_length": 3}, + "app_location": {"readonly": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + "central_server_vm_id": {"key": "centralServerVmId", "type": "str"}, + "managed_rg_storage_account_name": {"key": "managedRgStorageAccountName", "type": "str"}, + "app_location": {"key": "appLocation", "type": "str"}, + } + + def __init__( + self, + *, + central_server_vm_id: Optional[str] = None, + managed_rg_storage_account_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword central_server_vm_id: The virtual machine ID of the Central Server. + :paramtype central_server_vm_id: str + :keyword managed_rg_storage_account_name: The custom storage account name for the storage + account created by the service in the managed resource group created as part of VIS + deployment.:code:`
`:code:`
`Refer to the storage account naming rules `here + `_.:code:`
`:code:`
`If # pylint: disable=line-too-long + not provided, the service will create the storage account with a random name. + :paramtype managed_rg_storage_account_name: str + """ + super().__init__(**kwargs) + self.configuration_type: str = "Discovery" + self.central_server_vm_id = central_server_vm_id + self.managed_rg_storage_account_name = managed_rg_storage_account_name + self.app_location = None + + +class DiskConfiguration(_serialization.Model): + """The Disk Configuration Details. + + :ivar disk_volume_configurations: The disk configuration for the db volume. For HANA, Required + volumes are: ['hana/data', 'hana/log', hana/shared', 'usr/sap', 'os'], Optional volume : + ['backup']. + :vartype disk_volume_configurations: dict[str, + ~azure.mgmt.workloadssapvirtualinstance.models.DiskVolumeConfiguration] + """ + + _attribute_map = { + "disk_volume_configurations": {"key": "diskVolumeConfigurations", "type": "{DiskVolumeConfiguration}"}, + } + + def __init__( + self, + *, + disk_volume_configurations: Optional[Dict[str, "_models.DiskVolumeConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword disk_volume_configurations: The disk configuration for the db volume. For HANA, + Required volumes are: ['hana/data', 'hana/log', hana/shared', 'usr/sap', 'os'], Optional volume + : ['backup']. + :paramtype disk_volume_configurations: dict[str, + ~azure.mgmt.workloadssapvirtualinstance.models.DiskVolumeConfiguration] + """ + super().__init__(**kwargs) + self.disk_volume_configurations = disk_volume_configurations + + +class DiskDetails(_serialization.Model): + """The supported disk size details for a disk type. + + :ivar sku: The type of disk sku. For example, Standard_LRS, Standard_ZRS, Premium_LRS, + Premium_ZRS. + :vartype sku: ~azure.mgmt.workloadssapvirtualinstance.models.DiskSku + :ivar size_gb: The disk size in GB. + :vartype size_gb: int + :ivar minimum_supported_disk_count: The minimum supported disk count. + :vartype minimum_supported_disk_count: int + :ivar maximum_supported_disk_count: The maximum supported disk count. + :vartype maximum_supported_disk_count: int + :ivar iops_read_write: The disk Iops. + :vartype iops_read_write: int + :ivar mbps_read_write: The disk provisioned throughput in MBps. + :vartype mbps_read_write: int + :ivar disk_tier: The disk tier, e.g. P10, E10. + :vartype disk_tier: str + """ + + _attribute_map = { + "sku": {"key": "sku", "type": "DiskSku"}, + "size_gb": {"key": "sizeGB", "type": "int"}, + "minimum_supported_disk_count": {"key": "minimumSupportedDiskCount", "type": "int"}, + "maximum_supported_disk_count": {"key": "maximumSupportedDiskCount", "type": "int"}, + "iops_read_write": {"key": "iopsReadWrite", "type": "int"}, + "mbps_read_write": {"key": "mbpsReadWrite", "type": "int"}, + "disk_tier": {"key": "diskTier", "type": "str"}, + } + + def __init__( + self, + *, + sku: Optional["_models.DiskSku"] = None, + size_gb: Optional[int] = None, + minimum_supported_disk_count: Optional[int] = None, + maximum_supported_disk_count: Optional[int] = None, + iops_read_write: Optional[int] = None, + mbps_read_write: Optional[int] = None, + disk_tier: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: The type of disk sku. For example, Standard_LRS, Standard_ZRS, Premium_LRS, + Premium_ZRS. + :paramtype sku: ~azure.mgmt.workloadssapvirtualinstance.models.DiskSku + :keyword size_gb: The disk size in GB. + :paramtype size_gb: int + :keyword minimum_supported_disk_count: The minimum supported disk count. + :paramtype minimum_supported_disk_count: int + :keyword maximum_supported_disk_count: The maximum supported disk count. + :paramtype maximum_supported_disk_count: int + :keyword iops_read_write: The disk Iops. + :paramtype iops_read_write: int + :keyword mbps_read_write: The disk provisioned throughput in MBps. + :paramtype mbps_read_write: int + :keyword disk_tier: The disk tier, e.g. P10, E10. + :paramtype disk_tier: str + """ + super().__init__(**kwargs) + self.sku = sku + self.size_gb = size_gb + self.minimum_supported_disk_count = minimum_supported_disk_count + self.maximum_supported_disk_count = maximum_supported_disk_count + self.iops_read_write = iops_read_write + self.mbps_read_write = mbps_read_write + self.disk_tier = disk_tier + + +class DiskSku(_serialization.Model): + """The type of disk sku. For example, Standard_LRS, Standard_ZRS, Premium_LRS, Premium_ZRS. + + :ivar name: Defines the disk sku name. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". + :vartype name: str or ~azure.mgmt.workloadssapvirtualinstance.models.DiskSkuName + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Optional[Union[str, "_models.DiskSkuName"]] = None, **kwargs: Any) -> None: + """ + :keyword name: Defines the disk sku name. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". + :paramtype name: str or ~azure.mgmt.workloadssapvirtualinstance.models.DiskSkuName + """ + super().__init__(**kwargs) + self.name = name + + +class DiskVolumeConfiguration(_serialization.Model): + """The disk configuration required for the selected volume. + + :ivar count: The total number of disks required for the concerned volume. + :vartype count: int + :ivar size_gb: The disk size in GB. + :vartype size_gb: int + :ivar sku: The disk SKU details. + :vartype sku: ~azure.mgmt.workloadssapvirtualinstance.models.DiskSku + """ + + _attribute_map = { + "count": {"key": "count", "type": "int"}, + "size_gb": {"key": "sizeGB", "type": "int"}, + "sku": {"key": "sku", "type": "DiskSku"}, + } + + def __init__( + self, + *, + count: Optional[int] = None, + size_gb: Optional[int] = None, + sku: Optional["_models.DiskSku"] = None, + **kwargs: Any + ) -> None: + """ + :keyword count: The total number of disks required for the concerned volume. + :paramtype count: int + :keyword size_gb: The disk size in GB. + :paramtype size_gb: int + :keyword sku: The disk SKU details. + :paramtype sku: ~azure.mgmt.workloadssapvirtualinstance.models.DiskSku + """ + super().__init__(**kwargs) + self.count = count + self.size_gb = size_gb + self.sku = sku + + +class EnqueueReplicationServerProperties(_serialization.Model): + """Defines the SAP Enqueue Replication Server (ERS) properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ers_version: Defines the type of Enqueue Replication Server. Known values are: + "EnqueueReplicator1" and "EnqueueReplicator2". + :vartype ers_version: str or + ~azure.mgmt.workloadssapvirtualinstance.models.EnqueueReplicationServerType + :ivar instance_no: ERS Instance Number. + :vartype instance_no: str + :ivar hostname: ERS SAP Hostname. + :vartype hostname: str + :ivar kernel_version: ERS SAP Kernel Version. + :vartype kernel_version: str + :ivar kernel_patch: ERS SAP Kernel Patch level. + :vartype kernel_patch: str + :ivar ip_address: ERS SAP IP Address. + :vartype ip_address: str + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + """ + + _validation = { + "ers_version": {"readonly": True}, + "instance_no": {"readonly": True}, + "hostname": {"readonly": True}, + "kernel_version": {"readonly": True}, + "kernel_patch": {"readonly": True}, + "ip_address": {"readonly": True}, + "health": {"readonly": True}, + } + + _attribute_map = { + "ers_version": {"key": "ersVersion", "type": "str"}, + "instance_no": {"key": "instanceNo", "type": "str"}, + "hostname": {"key": "hostname", "type": "str"}, + "kernel_version": {"key": "kernelVersion", "type": "str"}, + "kernel_patch": {"key": "kernelPatch", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "health": {"key": "health", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.ers_version = None + self.instance_no = None + self.hostname = None + self.kernel_version = None + self.kernel_patch = None + self.ip_address = None + self.health = None + + +class EnqueueServerProperties(_serialization.Model): + """Defines the SAP Enqueue Server properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hostname: Enqueue Server SAP Hostname. + :vartype hostname: str + :ivar ip_address: Enqueue Server SAP IP Address. + :vartype ip_address: str + :ivar port: Enqueue Server Port. + :vartype port: int + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + """ + + _validation = { + "hostname": {"readonly": True}, + "ip_address": {"readonly": True}, + "port": {"readonly": True}, + "health": {"readonly": True}, + } + + _attribute_map = { + "hostname": {"key": "hostname", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "health": {"key": "health", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.hostname = None + self.ip_address = None + self.port = None + self.health = None + + +class ErrorAdditionalInfo(_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: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDefinition(_serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.workloadssapvirtualinstance.models.ErrorDefinition] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDefinition]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorDetail(_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.workloadssapvirtualinstance.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.workloadssapvirtualinstance.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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_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.workloadssapvirtualinstance.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.workloadssapvirtualinstance.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class SoftwareConfiguration(_serialization.Model): + """The SAP Software configuration Input. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ExternalInstallationSoftwareConfiguration, SAPInstallWithoutOSConfigSoftwareConfiguration, + ServiceInitiatedSoftwareConfiguration + + All required parameters must be populated in order to send to server. + + :ivar software_installation_type: The SAP software installation Type. Required. Known values + are: "ServiceInitiated", "SAPInstallWithoutOSConfig", and "External". + :vartype software_installation_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSoftwareInstallationType + """ + + _validation = { + "software_installation_type": {"required": True}, + } + + _attribute_map = { + "software_installation_type": {"key": "softwareInstallationType", "type": "str"}, + } + + _subtype_map = { + "software_installation_type": { + "External": "ExternalInstallationSoftwareConfiguration", + "SAPInstallWithoutOSConfig": "SAPInstallWithoutOSConfigSoftwareConfiguration", + "ServiceInitiated": "ServiceInitiatedSoftwareConfiguration", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.software_installation_type: Optional[str] = None + + +class ExternalInstallationSoftwareConfiguration(SoftwareConfiguration): # pylint: disable=name-too-long + """The SAP Software configuration Input when the software is installed externally outside the + service. + + All required parameters must be populated in order to send to server. + + :ivar software_installation_type: The SAP software installation Type. Required. Known values + are: "ServiceInitiated", "SAPInstallWithoutOSConfig", and "External". + :vartype software_installation_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSoftwareInstallationType + :ivar central_server_vm_id: The resource ID of the virtual machine containing the central + server instance. + :vartype central_server_vm_id: str + """ + + _validation = { + "software_installation_type": {"required": True}, + } + + _attribute_map = { + "software_installation_type": {"key": "softwareInstallationType", "type": "str"}, + "central_server_vm_id": {"key": "centralServerVmId", "type": "str"}, + } + + def __init__(self, *, central_server_vm_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword central_server_vm_id: The resource ID of the virtual machine containing the central + server instance. + :paramtype central_server_vm_id: str + """ + super().__init__(**kwargs) + self.software_installation_type: str = "External" + self.central_server_vm_id = central_server_vm_id + + +class GatewayServerProperties(_serialization.Model): + """Defines the SAP Gateway Server properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar port: Gateway Port. + :vartype port: int + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + """ + + _validation = { + "port": {"readonly": True}, + "health": {"readonly": True}, + } + + _attribute_map = { + "port": {"key": "port", "type": "int"}, + "health": {"key": "health", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.port = None + self.health = None + + +class HighAvailabilityConfiguration(_serialization.Model): + """Gets or sets the high availability configuration. + + All required parameters must be populated in order to send to server. + + :ivar high_availability_type: The high availability type. Required. Known values are: + "AvailabilitySet" and "AvailabilityZone". + :vartype high_availability_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPHighAvailabilityType + """ + + _validation = { + "high_availability_type": {"required": True}, + } + + _attribute_map = { + "high_availability_type": {"key": "highAvailabilityType", "type": "str"}, + } + + def __init__(self, *, high_availability_type: Union[str, "_models.SAPHighAvailabilityType"], **kwargs: Any) -> None: + """ + :keyword high_availability_type: The high availability type. Required. Known values are: + "AvailabilitySet" and "AvailabilityZone". + :paramtype high_availability_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPHighAvailabilityType + """ + super().__init__(**kwargs) + self.high_availability_type = high_availability_type + + +class HighAvailabilitySoftwareConfiguration(_serialization.Model): + """Gets or sets the HA software configuration. + + All required parameters must be populated in order to send to server. + + :ivar fencing_client_id: The fencing client id. Required. + :vartype fencing_client_id: str + :ivar fencing_client_password: The fencing client id secret/password. The secret should never + expire. This will be used pacemaker to start/stop the cluster VMs. Required. + :vartype fencing_client_password: str + """ + + _validation = { + "fencing_client_id": {"required": True}, + "fencing_client_password": {"required": True}, + } + + _attribute_map = { + "fencing_client_id": {"key": "fencingClientId", "type": "str"}, + "fencing_client_password": {"key": "fencingClientPassword", "type": "str"}, + } + + def __init__(self, *, fencing_client_id: str, fencing_client_password: str, **kwargs: Any) -> None: + """ + :keyword fencing_client_id: The fencing client id. Required. + :paramtype fencing_client_id: str + :keyword fencing_client_password: The fencing client id secret/password. The secret should + never expire. This will be used pacemaker to start/stop the cluster VMs. Required. + :paramtype fencing_client_password: str + """ + super().__init__(**kwargs) + self.fencing_client_id = fencing_client_id + self.fencing_client_password = fencing_client_password + + +class ImageReference(_serialization.Model): + """Specifies information about the image to use. You can specify information about platform + images, marketplace images, or virtual machine images. This element is required when you want + to use a platform image, marketplace image, or virtual machine image, but is not used in other + creation operations. NOTE: Image reference publisher and offer can only be set when you create + the scale set. + + :ivar publisher: The image publisher. + :vartype publisher: str + :ivar offer: Specifies the offer of the platform image or marketplace image used to create the + virtual machine. + :vartype offer: str + :ivar sku: The image SKU. + :vartype sku: str + :ivar version: Specifies the version of the platform image or marketplace image used to create + the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and + Build are decimal numbers. Specify 'latest' to use the latest version of an image available at + deploy time. Even if you use 'latest', the VM image will not automatically update after deploy + time even if a new version becomes available. + :vartype version: str + :ivar id: Specifies the ARM resource ID of the Azure Compute Gallery image version used for + creating ACSS VMs. You will need to provide this input when you choose to deploy virtual + machines in ACSS with OS image from the Azure Compute gallery. + :vartype id: str + """ + + _attribute_map = { + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "id": {"key": "id", "type": "str"}, + } + + def __init__( + self, + *, + publisher: Optional[str] = None, + offer: Optional[str] = None, + sku: Optional[str] = None, + version: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword publisher: The image publisher. + :paramtype publisher: str + :keyword offer: Specifies the offer of the platform image or marketplace image used to create + the virtual machine. + :paramtype offer: str + :keyword sku: The image SKU. + :paramtype sku: str + :keyword version: Specifies the version of the platform image or marketplace image used to + create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, + Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image + available at deploy time. Even if you use 'latest', the VM image will not automatically update + after deploy time even if a new version becomes available. + :paramtype version: str + :keyword id: Specifies the ARM resource ID of the Azure Compute Gallery image version used for + creating ACSS VMs. You will need to provide this input when you choose to deploy virtual + machines in ACSS with OS image from the Azure Compute gallery. + :paramtype id: str + """ + super().__init__(**kwargs) + self.publisher = publisher + self.offer = offer + self.sku = sku + self.version = version + self.id = id + + +class InfrastructureConfiguration(_serialization.Model): + """Deploy SAP Infrastructure Details. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SingleServerConfiguration, ThreeTierConfiguration + + All required parameters must be populated in order to send to server. + + :ivar deployment_type: The type of SAP deployment, single server or Three tier. Required. Known + values are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar app_resource_group: The application resource group where SAP system resources will be + deployed. Required. + :vartype app_resource_group: str + """ + + _validation = { + "deployment_type": {"required": True}, + "app_resource_group": {"required": True}, + } + + _attribute_map = { + "deployment_type": {"key": "deploymentType", "type": "str"}, + "app_resource_group": {"key": "appResourceGroup", "type": "str"}, + } + + _subtype_map = { + "deployment_type": {"SingleServer": "SingleServerConfiguration", "ThreeTier": "ThreeTierConfiguration"} + } + + def __init__(self, *, app_resource_group: str, **kwargs: Any) -> None: + """ + :keyword app_resource_group: The application resource group where SAP system resources will be + deployed. Required. + :paramtype app_resource_group: str + """ + super().__init__(**kwargs) + self.deployment_type: Optional[str] = None + self.app_resource_group = app_resource_group + + +class OSConfiguration(_serialization.Model): + """Defines the OS configuration. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + LinuxConfiguration, WindowsConfiguration + + All required parameters must be populated in order to send to server. + + :ivar os_type: The OS Type. Required. Known values are: "Linux" and "Windows". + :vartype os_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.OSType + """ + + _validation = { + "os_type": {"required": True}, + } + + _attribute_map = { + "os_type": {"key": "osType", "type": "str"}, + } + + _subtype_map = {"os_type": {"Linux": "LinuxConfiguration", "Windows": "WindowsConfiguration"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.os_type: Optional[str] = None + + +class LinuxConfiguration(OSConfiguration): + """Specifies the Linux operating system settings on the virtual machine. + :code:`
`:code:`
`For a list of supported Linux distributions, see `Linux on + Azure-Endorsed Distributions + `_. + + All required parameters must be populated in order to send to server. + + :ivar os_type: The OS Type. Required. Known values are: "Linux" and "Windows". + :vartype os_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.OSType + :ivar disable_password_authentication: Specifies whether password authentication should be + disabled. + :vartype disable_password_authentication: bool + :ivar ssh: Specifies the ssh key configuration for a Linux OS. (This property is deprecated, + please use 'sshKeyPair' instead). + :vartype ssh: ~azure.mgmt.workloadssapvirtualinstance.models.SshConfiguration + :ivar ssh_key_pair: The SSH Key-pair used to authenticate with the VM's. + :vartype ssh_key_pair: ~azure.mgmt.workloadssapvirtualinstance.models.SshKeyPair + """ + + _validation = { + "os_type": {"required": True}, + } + + _attribute_map = { + "os_type": {"key": "osType", "type": "str"}, + "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, + "ssh": {"key": "ssh", "type": "SshConfiguration"}, + "ssh_key_pair": {"key": "sshKeyPair", "type": "SshKeyPair"}, + } + + def __init__( + self, + *, + disable_password_authentication: Optional[bool] = None, + ssh: Optional["_models.SshConfiguration"] = None, + ssh_key_pair: Optional["_models.SshKeyPair"] = None, + **kwargs: Any + ) -> None: + """ + :keyword disable_password_authentication: Specifies whether password authentication should be + disabled. + :paramtype disable_password_authentication: bool + :keyword ssh: Specifies the ssh key configuration for a Linux OS. (This property is deprecated, + please use 'sshKeyPair' instead). + :paramtype ssh: ~azure.mgmt.workloadssapvirtualinstance.models.SshConfiguration + :keyword ssh_key_pair: The SSH Key-pair used to authenticate with the VM's. + :paramtype ssh_key_pair: ~azure.mgmt.workloadssapvirtualinstance.models.SshKeyPair + """ + super().__init__(**kwargs) + self.os_type: str = "Linux" + self.disable_password_authentication = disable_password_authentication + self.ssh = ssh + self.ssh_key_pair = ssh_key_pair + + +class LoadBalancerDetails(_serialization.Model): + """The Load Balancer details such as Load Balancer ID. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class LoadBalancerResourceNames(_serialization.Model): + """The resource names object for load balancer and related resources. + + :ivar load_balancer_name: The full resource name for load balancer. If this value is not + provided, load balancer will be name as {ASCS/DB}-loadBalancer. + :vartype load_balancer_name: str + :ivar frontend_ip_configuration_names: The list of frontend IP configuration names. If provided + as input, size of this list should be 2 for cs layer and should be 1 for database layer. + :vartype frontend_ip_configuration_names: list[str] + :ivar backend_pool_names: The list of backend pool names. Currently, ACSS deploys only one + backend pool and hence, size of this list should be 1. + :vartype backend_pool_names: list[str] + :ivar health_probe_names: The list of health probe names. If provided as input, size of this + list should be 2 for cs layer and should be 1 for database layer. + :vartype health_probe_names: list[str] + """ + + _validation = { + "frontend_ip_configuration_names": {"max_items": 2, "min_items": 0}, + "backend_pool_names": {"max_items": 1, "min_items": 0}, + "health_probe_names": {"max_items": 2, "min_items": 0}, + } + + _attribute_map = { + "load_balancer_name": {"key": "loadBalancerName", "type": "str"}, + "frontend_ip_configuration_names": {"key": "frontendIpConfigurationNames", "type": "[str]"}, + "backend_pool_names": {"key": "backendPoolNames", "type": "[str]"}, + "health_probe_names": {"key": "healthProbeNames", "type": "[str]"}, + } + + def __init__( + self, + *, + load_balancer_name: Optional[str] = None, + frontend_ip_configuration_names: Optional[List[str]] = None, + backend_pool_names: Optional[List[str]] = None, + health_probe_names: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword load_balancer_name: The full resource name for load balancer. If this value is not + provided, load balancer will be name as {ASCS/DB}-loadBalancer. + :paramtype load_balancer_name: str + :keyword frontend_ip_configuration_names: The list of frontend IP configuration names. If + provided as input, size of this list should be 2 for cs layer and should be 1 for database + layer. + :paramtype frontend_ip_configuration_names: list[str] + :keyword backend_pool_names: The list of backend pool names. Currently, ACSS deploys only one + backend pool and hence, size of this list should be 1. + :paramtype backend_pool_names: list[str] + :keyword health_probe_names: The list of health probe names. If provided as input, size of this + list should be 2 for cs layer and should be 1 for database layer. + :paramtype health_probe_names: list[str] + """ + super().__init__(**kwargs) + self.load_balancer_name = load_balancer_name + self.frontend_ip_configuration_names = frontend_ip_configuration_names + self.backend_pool_names = backend_pool_names + self.health_probe_names = health_probe_names + + +class ManagedRGConfiguration(_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: Any) -> None: + """ + :keyword name: Managed resource group name. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class MessageServerProperties(_serialization.Model): + """Defines the SAP message server properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ms_port: message server port. + :vartype ms_port: int + :ivar internal_ms_port: message server internal MS port. + :vartype internal_ms_port: int + :ivar http_port: message server HTTP Port. + :vartype http_port: int + :ivar https_port: message server HTTPS Port. + :vartype https_port: int + :ivar hostname: message server SAP Hostname. + :vartype hostname: str + :ivar ip_address: message server IP Address. + :vartype ip_address: str + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + """ + + _validation = { + "ms_port": {"readonly": True}, + "internal_ms_port": {"readonly": True}, + "http_port": {"readonly": True}, + "https_port": {"readonly": True}, + "hostname": {"readonly": True}, + "ip_address": {"readonly": True}, + "health": {"readonly": True}, + } + + _attribute_map = { + "ms_port": {"key": "msPort", "type": "int"}, + "internal_ms_port": {"key": "internalMsPort", "type": "int"}, + "http_port": {"key": "httpPort", "type": "int"}, + "https_port": {"key": "httpsPort", "type": "int"}, + "hostname": {"key": "hostname", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "health": {"key": "health", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.ms_port = None + self.internal_ms_port = None + self.http_port = None + self.https_port = None + self.hostname = None + self.ip_address = None + self.health = None + + +class MountFileShareConfiguration(FileShareConfiguration): + """Gets or sets the file share configuration where the transport directory fileshare already + exists, and user wishes to mount the fileshare as a part of the create infra flow. + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The type of file share config. Required. Known values are: "Skip", + "CreateAndMount", and "Mount". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ConfigurationType + :ivar id: The fileshare resource ID. Required. + :vartype id: str + :ivar private_endpoint_id: The private endpoint resource ID. Required. + :vartype private_endpoint_id: str + """ + + _validation = { + "configuration_type": {"required": True}, + "id": {"required": True}, + "private_endpoint_id": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "private_endpoint_id": {"key": "privateEndpointId", "type": "str"}, + } + + def __init__( + self, *, id: str, private_endpoint_id: str, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: + """ + :keyword id: The fileshare resource ID. Required. + :paramtype id: str + :keyword private_endpoint_id: The private endpoint resource ID. Required. + :paramtype private_endpoint_id: str + """ + super().__init__(**kwargs) + self.configuration_type: str = "Mount" + self.id = id + self.private_endpoint_id = private_endpoint_id + + +class NetworkConfiguration(_serialization.Model): + """Defines the network configuration type for SAP system infrastructure that is being deployed. + + :ivar is_secondary_ip_enabled: Specifies whether a secondary IP address should be added to the + network interface on all VMs of the SAP system being deployed. + :vartype is_secondary_ip_enabled: bool + """ + + _attribute_map = { + "is_secondary_ip_enabled": {"key": "isSecondaryIpEnabled", "type": "bool"}, + } + + def __init__(self, *, is_secondary_ip_enabled: bool = False, **kwargs: Any) -> None: + """ + :keyword is_secondary_ip_enabled: Specifies whether a secondary IP address should be added to + the network interface on all VMs of the SAP system being deployed. + :paramtype is_secondary_ip_enabled: bool + """ + super().__init__(**kwargs) + self.is_secondary_ip_enabled = is_secondary_ip_enabled + + +class NetworkInterfaceResourceNames(_serialization.Model): + """The resource names object for network interface and related resources. + + :ivar network_interface_name: The full name for network interface. If name is not provided, + service uses a default name based on the deployment type. For SingleServer, default name is + {SID}-Nic. In case of HA-AvZone systems, default name will be {SID}-{App/ASCS/DB}-Zone{A/B}-Nic + with an incrementor at the end in case of more than 1 instance per layer. For distributed and + HA-AvSet systems, default name will be {SID}-{App/ASCS/DB}-Nic with an incrementor at the end + in case of more than 1 instance per layer. + :vartype network_interface_name: str + """ + + _attribute_map = { + "network_interface_name": {"key": "networkInterfaceName", "type": "str"}, + } + + def __init__(self, *, network_interface_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword network_interface_name: The full name for network interface. If name is not provided, + service uses a default name based on the deployment type. For SingleServer, default name is + {SID}-Nic. In case of HA-AvZone systems, default name will be {SID}-{App/ASCS/DB}-Zone{A/B}-Nic + with an incrementor at the end in case of more than 1 instance per layer. For distributed and + HA-AvSet systems, default name will be {SID}-{App/ASCS/DB}-Nic with an incrementor at the end + in case of more than 1 instance per layer. + :paramtype network_interface_name: str + """ + super().__init__(**kwargs) + self.network_interface_name = network_interface_name + + +class Operation(_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.workloadssapvirtualinstance.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". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.workloadssapvirtualinstance.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.workloadssapvirtualinstance.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["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.workloadssapvirtualinstance.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_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.workloadssapvirtualinstance.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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :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.workloadssapvirtualinstance.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.workloadssapvirtualinstance.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, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :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.workloadssapvirtualinstance.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.workloadssapvirtualinstance.models.ErrorDetail + """ + super().__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 OSProfile(_serialization.Model): + """Specifies the operating system settings for the virtual machine. Some of the settings cannot be + changed once VM is provisioned. + + :ivar admin_username: Specifies the name of the administrator account. :code:`
`:code:`
` + This property cannot be updated after the VM is created. :code:`
`:code:`
` + **Windows-only restriction:** Cannot end in "." :code:`
`:code:`
` **Disallowed values:** + "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", + "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", + "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", + "test3", "user4", "user5". :code:`
`:code:`
` **Minimum-length (Linux):** 1 character + :code:`
`:code:`
` **Max-length (Linux):** 64 characters :code:`
`:code:`
` + **Max-length (Windows):** 20 characters. + :vartype admin_username: str + :ivar admin_password: Specifies the password of the administrator account. + :code:`
`:code:`
` **Minimum-length (Windows):** 8 characters :code:`
`:code:`
` + **Minimum-length (Linux):** 6 characters :code:`
`:code:`
` **Max-length (Windows):** 123 + characters :code:`
`:code:`
` **Max-length (Linux):** 72 characters + :code:`
`:code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be + fulfilled :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a + digit :code:`
` Has a special character (Regex match [\W_]) :code:`
`:code:`
` + **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", + "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`:code:`
` For + resetting the password, see `How to reset the Remote Desktop service or its login password in a + Windows VM `_ + :code:`
`:code:`
` For resetting root password, see `Manage users, SSH, and check or + repair disks on Azure Linux VMs using the VMAccess Extension + `_. + :vartype admin_password: str + :ivar os_configuration: Specifies Windows operating system settings on the virtual machine. + :vartype os_configuration: ~azure.mgmt.workloadssapvirtualinstance.models.OSConfiguration + """ + + _attribute_map = { + "admin_username": {"key": "adminUsername", "type": "str"}, + "admin_password": {"key": "adminPassword", "type": "str"}, + "os_configuration": {"key": "osConfiguration", "type": "OSConfiguration"}, + } + + def __init__( + self, + *, + admin_username: Optional[str] = None, + admin_password: Optional[str] = None, + os_configuration: Optional["_models.OSConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword admin_username: Specifies the name of the administrator account. + :code:`
`:code:`
` This property cannot be updated after the VM is created. + :code:`
`:code:`
` **Windows-only restriction:** Cannot end in "." + :code:`
`:code:`
` **Disallowed values:** "administrator", "admin", "user", "user1", + "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", + "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", + "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". + :code:`
`:code:`
` **Minimum-length (Linux):** 1 character :code:`
`:code:`
` + **Max-length (Linux):** 64 characters :code:`
`:code:`
` **Max-length (Windows):** 20 + characters. + :paramtype admin_username: str + :keyword admin_password: Specifies the password of the administrator account. + :code:`
`:code:`
` **Minimum-length (Windows):** 8 characters :code:`
`:code:`
` + **Minimum-length (Linux):** 6 characters :code:`
`:code:`
` **Max-length (Windows):** 123 + characters :code:`
`:code:`
` **Max-length (Linux):** 72 characters + :code:`
`:code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be + fulfilled :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a + digit :code:`
` Has a special character (Regex match [\W_]) :code:`
`:code:`
` + **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", + "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`:code:`
` For + resetting the password, see `How to reset the Remote Desktop service or its login password in a + Windows VM `_ + :code:`
`:code:`
` For resetting root password, see `Manage users, SSH, and check or + repair disks on Azure Linux VMs using the VMAccess Extension + `_. + :paramtype admin_password: str + :keyword os_configuration: Specifies Windows operating system settings on the virtual machine. + :paramtype os_configuration: ~azure.mgmt.workloadssapvirtualinstance.models.OSConfiguration + """ + super().__init__(**kwargs) + self.admin_username = admin_username + self.admin_password = admin_password + self.os_configuration = os_configuration + + +class OsSapConfiguration(_serialization.Model): + """Defines the OS and SAP Configurations for Deployment. + + :ivar deployer_vm_packages: The url and storage account ID where deployer VM packages are + uploaded. + :vartype deployer_vm_packages: + ~azure.mgmt.workloadssapvirtualinstance.models.DeployerVmPackages + :ivar sap_fqdn: The FQDN to set for the SAP system. + :vartype sap_fqdn: str + """ + + _attribute_map = { + "deployer_vm_packages": {"key": "deployerVmPackages", "type": "DeployerVmPackages"}, + "sap_fqdn": {"key": "sapFqdn", "type": "str"}, + } + + def __init__( + self, + *, + deployer_vm_packages: Optional["_models.DeployerVmPackages"] = None, + sap_fqdn: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword deployer_vm_packages: The url and storage account ID where deployer VM packages are + uploaded. + :paramtype deployer_vm_packages: + ~azure.mgmt.workloadssapvirtualinstance.models.DeployerVmPackages + :keyword sap_fqdn: The FQDN to set for the SAP system. + :paramtype sap_fqdn: str + """ + super().__init__(**kwargs) + self.deployer_vm_packages = deployer_vm_packages + self.sap_fqdn = sap_fqdn + + +class Resource(_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}. # pylint: disable=line-too-long + :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.workloadssapvirtualinstance.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: Any) -> None: + """ """ + super().__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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :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.workloadssapvirtualinstance.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :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: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class SAPApplicationServerInstance(TrackedResource): + """Define the SAP Application Server Instance resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :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.workloadssapvirtualinstance.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Defines the SAP Application Server instance properties. + :vartype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "SAPApplicationServerProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.SAPApplicationServerProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Defines the SAP Application Server instance properties. + :paramtype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class SAPApplicationServerInstanceList(_serialization.Model): + """Defines the collection of SAP Application Server Instance resources. + + :ivar value: Gets the list of SAP Application Server instance resources. + :vartype value: + list[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :ivar next_link: Gets the value of next link. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SAPApplicationServerInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SAPApplicationServerInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets the list of SAP Application Server instance resources. + :paramtype value: + list[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :keyword next_link: Gets the value of next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SAPApplicationServerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Defines the SAP Application Server instance properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar instance_no: Application server Instance Number. + :vartype instance_no: str + :ivar subnet: Application server Subnet. + :vartype subnet: str + :ivar hostname: Application server instance SAP hostname. + :vartype hostname: str + :ivar kernel_version: Application server instance SAP Kernel Version. + :vartype kernel_version: str + :ivar kernel_patch: Application server instance SAP Kernel Patch level. + :vartype kernel_patch: str + :ivar ip_address: Application server instance SAP IP Address. + :vartype ip_address: str + :ivar gateway_port: Application server instance gateway Port. + :vartype gateway_port: int + :ivar icm_http_port: Application server instance ICM HTTP Port. + :vartype icm_http_port: int + :ivar icm_https_port: Application server instance ICM HTTPS Port. + :vartype icm_https_port: int + :ivar dispatcher_status: Application server instance dispatcher status. + :vartype dispatcher_status: str + :ivar load_balancer_details: The Load Balancer details such as LoadBalancer ID attached to + Application Server Virtual Machines. + :vartype load_balancer_details: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerDetails + :ivar vm_details: The list of virtual machines. + :vartype vm_details: + list[~azure.mgmt.workloadssapvirtualinstance.models.ApplicationServerVmDetails] + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", "Unavailable", and "SoftShutdown". + :vartype status: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceStatus + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SapVirtualInstanceProvisioningState + :ivar errors: Defines the Application Instance errors. + :vartype errors: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceError + """ + + _validation = { + "instance_no": {"readonly": True}, + "subnet": {"readonly": True}, + "hostname": {"readonly": True}, + "kernel_version": {"readonly": True}, + "kernel_patch": {"readonly": True}, + "ip_address": {"readonly": True}, + "gateway_port": {"readonly": True}, + "icm_http_port": {"readonly": True}, + "icm_https_port": {"readonly": True}, + "dispatcher_status": {"readonly": True}, + "load_balancer_details": {"readonly": True}, + "vm_details": {"readonly": True}, + "status": {"readonly": True}, + "health": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, + } + + _attribute_map = { + "instance_no": {"key": "instanceNo", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "hostname": {"key": "hostname", "type": "str"}, + "kernel_version": {"key": "kernelVersion", "type": "str"}, + "kernel_patch": {"key": "kernelPatch", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "gateway_port": {"key": "gatewayPort", "type": "int"}, + "icm_http_port": {"key": "icmHttpPort", "type": "int"}, + "icm_https_port": {"key": "icmHttpsPort", "type": "int"}, + "dispatcher_status": {"key": "dispatcherStatus", "type": "str"}, + "load_balancer_details": {"key": "loadBalancerDetails", "type": "LoadBalancerDetails"}, + "vm_details": {"key": "vmDetails", "type": "[ApplicationServerVmDetails]"}, + "status": {"key": "status", "type": "str"}, + "health": {"key": "health", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "errors": {"key": "errors", "type": "SAPVirtualInstanceError"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.instance_no = None + self.subnet = None + self.hostname = None + self.kernel_version = None + self.kernel_patch = None + self.ip_address = None + self.gateway_port = None + self.icm_http_port = None + self.icm_https_port = None + self.dispatcher_status = None + self.load_balancer_details = None + self.vm_details = None + self.status = None + self.health = None + self.provisioning_state = None + self.errors = None + + +class SAPAvailabilityZoneDetailsRequest(_serialization.Model): + """The SAP request to get list of availability zones. + + All required parameters must be populated in order to send to server. + + :ivar app_location: The geo-location where the SAP resources will be created. Required. + :vartype app_location: str + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". + :vartype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :ivar database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: "HANA" + and "DB2". + :vartype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + """ + + _validation = { + "app_location": {"required": True}, + "sap_product": {"required": True}, + "database_type": {"required": True}, + } + + _attribute_map = { + "app_location": {"key": "appLocation", "type": "str"}, + "sap_product": {"key": "sapProduct", "type": "str"}, + "database_type": {"key": "databaseType", "type": "str"}, + } + + def __init__( + self, + *, + app_location: str, + sap_product: Union[str, "_models.SAPProductType"], + database_type: Union[str, "_models.SAPDatabaseType"], + **kwargs: Any + ) -> None: + """ + :keyword app_location: The geo-location where the SAP resources will be created. Required. + :paramtype app_location: str + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". + :paramtype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :keyword database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: + "HANA" and "DB2". + :paramtype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + """ + super().__init__(**kwargs) + self.app_location = app_location + self.sap_product = sap_product + self.database_type = database_type + + +class SAPAvailabilityZoneDetailsResult(_serialization.Model): + """The list of supported availability zone pairs which are part of SAP HA deployment. + + :ivar availability_zone_pairs: Gets the list of availability zone pairs. + :vartype availability_zone_pairs: + list[~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZonePair] + """ + + _attribute_map = { + "availability_zone_pairs": {"key": "availabilityZonePairs", "type": "[SAPAvailabilityZonePair]"}, + } + + def __init__( + self, *, availability_zone_pairs: Optional[List["_models.SAPAvailabilityZonePair"]] = None, **kwargs: Any + ) -> None: + """ + :keyword availability_zone_pairs: Gets the list of availability zone pairs. + :paramtype availability_zone_pairs: + list[~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZonePair] + """ + super().__init__(**kwargs) + self.availability_zone_pairs = availability_zone_pairs + + +class SAPAvailabilityZonePair(_serialization.Model): + """The SAP Availability Zone Pair. + + :ivar zone_a: The zone A. + :vartype zone_a: int + :ivar zone_b: The zone B. + :vartype zone_b: int + """ + + _attribute_map = { + "zone_a": {"key": "zoneA", "type": "int"}, + "zone_b": {"key": "zoneB", "type": "int"}, + } + + def __init__(self, *, zone_a: Optional[int] = None, zone_b: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword zone_a: The zone A. + :paramtype zone_a: int + :keyword zone_b: The zone B. + :paramtype zone_b: int + """ + super().__init__(**kwargs) + self.zone_a = zone_a + self.zone_b = zone_b + + +class SAPCentralInstanceList(_serialization.Model): + """Defines the collection of SAP Central Services Instance resources. + + :ivar value: Gets the list of SAP central services instance resources. + :vartype value: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :ivar next_link: Gets the value of next link. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SAPCentralServerInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SAPCentralServerInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets the list of SAP central services instance resources. + :paramtype value: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :keyword next_link: Gets the value of next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SAPCentralServerInstance(TrackedResource): + """Define the SAP Central Services Instance resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :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.workloadssapvirtualinstance.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Defines the SAP Central Services Instance properties. + :vartype properties: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "SAPCentralServerProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.SAPCentralServerProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Defines the SAP Central Services Instance properties. + :paramtype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class SAPCentralServerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Defines the SAP Central Services Instance properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar instance_no: The central services instance number. + :vartype instance_no: str + :ivar subnet: The central services instance subnet. + :vartype subnet: str + :ivar message_server_properties: Defines the SAP message server properties. + :vartype message_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.MessageServerProperties + :ivar enqueue_server_properties: Defines the SAP Enqueue Server properties. + :vartype enqueue_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.EnqueueServerProperties + :ivar gateway_server_properties: Defines the SAP Gateway Server properties. + :vartype gateway_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.GatewayServerProperties + :ivar enqueue_replication_server_properties: Defines the SAP Enqueue Replication Server (ERS) + properties. + :vartype enqueue_replication_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.EnqueueReplicationServerProperties + :ivar kernel_version: The central services instance Kernel Version. + :vartype kernel_version: str + :ivar kernel_patch: The central services instance Kernel Patch level. + :vartype kernel_patch: str + :ivar load_balancer_details: The Load Balancer details such as LoadBalancer ID attached to ASCS + Virtual Machines. + :vartype load_balancer_details: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerDetails + :ivar vm_details: The list of virtual machines corresponding to the Central Services instance. + :vartype vm_details: + list[~azure.mgmt.workloadssapvirtualinstance.models.CentralServerVmDetails] + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", "Unavailable", and "SoftShutdown". + :vartype status: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceStatus + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SapVirtualInstanceProvisioningState + :ivar errors: Defines the errors related to SAP Central Services Instance resource. + :vartype errors: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceError + """ + + _validation = { + "instance_no": {"readonly": True}, + "subnet": {"readonly": True}, + "kernel_version": {"readonly": True}, + "kernel_patch": {"readonly": True}, + "load_balancer_details": {"readonly": True}, + "vm_details": {"readonly": True}, + "status": {"readonly": True}, + "health": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, + } + + _attribute_map = { + "instance_no": {"key": "instanceNo", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "message_server_properties": {"key": "messageServerProperties", "type": "MessageServerProperties"}, + "enqueue_server_properties": {"key": "enqueueServerProperties", "type": "EnqueueServerProperties"}, + "gateway_server_properties": {"key": "gatewayServerProperties", "type": "GatewayServerProperties"}, + "enqueue_replication_server_properties": { + "key": "enqueueReplicationServerProperties", + "type": "EnqueueReplicationServerProperties", + }, + "kernel_version": {"key": "kernelVersion", "type": "str"}, + "kernel_patch": {"key": "kernelPatch", "type": "str"}, + "load_balancer_details": {"key": "loadBalancerDetails", "type": "LoadBalancerDetails"}, + "vm_details": {"key": "vmDetails", "type": "[CentralServerVmDetails]"}, + "status": {"key": "status", "type": "str"}, + "health": {"key": "health", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "errors": {"key": "errors", "type": "SAPVirtualInstanceError"}, + } + + def __init__( + self, + *, + message_server_properties: Optional["_models.MessageServerProperties"] = None, + enqueue_server_properties: Optional["_models.EnqueueServerProperties"] = None, + gateway_server_properties: Optional["_models.GatewayServerProperties"] = None, + enqueue_replication_server_properties: Optional["_models.EnqueueReplicationServerProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword message_server_properties: Defines the SAP message server properties. + :paramtype message_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.MessageServerProperties + :keyword enqueue_server_properties: Defines the SAP Enqueue Server properties. + :paramtype enqueue_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.EnqueueServerProperties + :keyword gateway_server_properties: Defines the SAP Gateway Server properties. + :paramtype gateway_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.GatewayServerProperties + :keyword enqueue_replication_server_properties: Defines the SAP Enqueue Replication Server + (ERS) properties. + :paramtype enqueue_replication_server_properties: + ~azure.mgmt.workloadssapvirtualinstance.models.EnqueueReplicationServerProperties + """ + super().__init__(**kwargs) + self.instance_no = None + self.subnet = None + self.message_server_properties = message_server_properties + self.enqueue_server_properties = enqueue_server_properties + self.gateway_server_properties = gateway_server_properties + self.enqueue_replication_server_properties = enqueue_replication_server_properties + self.kernel_version = None + self.kernel_patch = None + self.load_balancer_details = None + self.vm_details = None + self.status = None + self.health = None + self.provisioning_state = None + self.errors = None + + +class SAPDatabaseInstance(TrackedResource): + """Define the Database resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :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.workloadssapvirtualinstance.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Defines the Database properties. + :vartype properties: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "SAPDatabaseProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.SAPDatabaseProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Defines the Database properties. + :paramtype properties: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class SAPDatabaseInstanceList(_serialization.Model): + """Defines the collection of SAP Database Instances. + + :ivar value: Gets the list of SAP Database instances. + :vartype value: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :ivar next_link: Gets the value of next link. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SAPDatabaseInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SAPDatabaseInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets the list of SAP Database instances. + :paramtype value: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :keyword next_link: Gets the value of next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SAPDatabaseProperties(_serialization.Model): + """Defines the Database properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subnet: Database subnet. + :vartype subnet: str + :ivar database_sid: Database SID name. + :vartype database_sid: str + :ivar database_type: Database type, that is if the DB is HANA, DB2, Oracle, SAP ASE, Max DB or + MS SQL Server. + :vartype database_type: str + :ivar ip_address: Database IP Address. + :vartype ip_address: str + :ivar load_balancer_details: The Load Balancer details such as LoadBalancer ID attached to + Database Virtual Machines. + :vartype load_balancer_details: + ~azure.mgmt.workloadssapvirtualinstance.models.LoadBalancerDetails + :ivar vm_details: The list of virtual machines corresponding to the Database resource. + :vartype vm_details: list[~azure.mgmt.workloadssapvirtualinstance.models.DatabaseVmDetails] + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", "Unavailable", and "SoftShutdown". + :vartype status: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceStatus + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SapVirtualInstanceProvisioningState + :ivar errors: Defines the errors related to Database resource. + :vartype errors: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceError + """ + + _validation = { + "subnet": {"readonly": True}, + "database_sid": {"readonly": True}, + "database_type": {"readonly": True}, + "ip_address": {"readonly": True}, + "load_balancer_details": {"readonly": True}, + "vm_details": {"readonly": True}, + "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, + } + + _attribute_map = { + "subnet": {"key": "subnet", "type": "str"}, + "database_sid": {"key": "databaseSid", "type": "str"}, + "database_type": {"key": "databaseType", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "load_balancer_details": {"key": "loadBalancerDetails", "type": "LoadBalancerDetails"}, + "vm_details": {"key": "vmDetails", "type": "[DatabaseVmDetails]"}, + "status": {"key": "status", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "errors": {"key": "errors", "type": "SAPVirtualInstanceError"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.subnet = None + self.database_sid = None + self.database_type = None + self.ip_address = None + self.load_balancer_details = None + self.vm_details = None + self.status = None + self.provisioning_state = None + self.errors = None + + +class SAPDiskConfiguration(_serialization.Model): + """The SAP Disk Configuration contains 'recommended disk' details and list of supported disks + detail for a volume type. + + :ivar recommended_configuration: The recommended disk details for a given VM Sku. + :vartype recommended_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.DiskVolumeConfiguration + :ivar supported_configurations: The list of supported disks for a given VM Sku. + :vartype supported_configurations: + list[~azure.mgmt.workloadssapvirtualinstance.models.DiskDetails] + """ + + _attribute_map = { + "recommended_configuration": {"key": "recommendedConfiguration", "type": "DiskVolumeConfiguration"}, + "supported_configurations": {"key": "supportedConfigurations", "type": "[DiskDetails]"}, + } + + def __init__( + self, + *, + recommended_configuration: Optional["_models.DiskVolumeConfiguration"] = None, + supported_configurations: Optional[List["_models.DiskDetails"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword recommended_configuration: The recommended disk details for a given VM Sku. + :paramtype recommended_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.DiskVolumeConfiguration + :keyword supported_configurations: The list of supported disks for a given VM Sku. + :paramtype supported_configurations: + list[~azure.mgmt.workloadssapvirtualinstance.models.DiskDetails] + """ + super().__init__(**kwargs) + self.recommended_configuration = recommended_configuration + self.supported_configurations = supported_configurations + + +class SAPDiskConfigurationsRequest(_serialization.Model): + """The SAP request to get list of disk configurations. + + All required parameters must be populated in order to send to server. + + :ivar app_location: The geo-location where the SAP resources will be created. Required. + :vartype app_location: str + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :vartype environment: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". + :vartype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :ivar database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: "HANA" + and "DB2". + :vartype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :ivar deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known values + are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar db_vm_sku: The VM SKU for database instance. Required. + :vartype db_vm_sku: str + """ + + _validation = { + "app_location": {"required": True}, + "environment": {"required": True}, + "sap_product": {"required": True}, + "database_type": {"required": True}, + "deployment_type": {"required": True}, + "db_vm_sku": {"required": True}, + } + + _attribute_map = { + "app_location": {"key": "appLocation", "type": "str"}, + "environment": {"key": "environment", "type": "str"}, + "sap_product": {"key": "sapProduct", "type": "str"}, + "database_type": {"key": "databaseType", "type": "str"}, + "deployment_type": {"key": "deploymentType", "type": "str"}, + "db_vm_sku": {"key": "dbVmSku", "type": "str"}, + } + + def __init__( + self, + *, + app_location: str, + environment: Union[str, "_models.SAPEnvironmentType"], + sap_product: Union[str, "_models.SAPProductType"], + database_type: Union[str, "_models.SAPDatabaseType"], + deployment_type: Union[str, "_models.SAPDeploymentType"], + db_vm_sku: str, + **kwargs: Any + ) -> None: + """ + :keyword app_location: The geo-location where the SAP resources will be created. Required. + :paramtype app_location: str + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :paramtype environment: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". + :paramtype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :keyword database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: + "HANA" and "DB2". + :paramtype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :keyword deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known + values are: "SingleServer" and "ThreeTier". + :paramtype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :keyword db_vm_sku: The VM SKU for database instance. Required. + :paramtype db_vm_sku: str + """ + super().__init__(**kwargs) + self.app_location = app_location + self.environment = environment + self.sap_product = sap_product + self.database_type = database_type + self.deployment_type = deployment_type + self.db_vm_sku = db_vm_sku + + +class SAPDiskConfigurationsResult(_serialization.Model): + """The list of disk configuration for vmSku which are part of SAP deployment. + + :ivar volume_configurations: The disk configuration for the db volume. For HANA, Required + volumes are: ['hana/data', 'hana/log', hana/shared', 'usr/sap', 'os'], Optional volume : + ['backup']. + :vartype volume_configurations: dict[str, + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfiguration] + """ + + _attribute_map = { + "volume_configurations": {"key": "volumeConfigurations", "type": "{SAPDiskConfiguration}"}, + } + + def __init__( + self, *, volume_configurations: Optional[Dict[str, "_models.SAPDiskConfiguration"]] = None, **kwargs: Any + ) -> None: + """ + :keyword volume_configurations: The disk configuration for the db volume. For HANA, Required + volumes are: ['hana/data', 'hana/log', hana/shared', 'usr/sap', 'os'], Optional volume : + ['backup']. + :paramtype volume_configurations: dict[str, + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfiguration] + """ + super().__init__(**kwargs) + self.volume_configurations = volume_configurations + + +class SAPInstallWithoutOSConfigSoftwareConfiguration(SoftwareConfiguration): # pylint: disable=name-too-long + """The SAP Software configuration Input when the software is to be installed by service without OS + Configurations. + + All required parameters must be populated in order to send to server. + + :ivar software_installation_type: The SAP software installation Type. Required. Known values + are: "ServiceInitiated", "SAPInstallWithoutOSConfig", and "External". + :vartype software_installation_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSoftwareInstallationType + :ivar bom_url: The URL to the SAP Build of Materials(BOM) file. Required. + :vartype bom_url: str + :ivar sap_bits_storage_account_id: The SAP bits storage account id. Required. + :vartype sap_bits_storage_account_id: str + :ivar software_version: The software version to install. Required. + :vartype software_version: str + :ivar high_availability_software_configuration: Gets or sets the HA software configuration. + :vartype high_availability_software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.HighAvailabilitySoftwareConfiguration + """ + + _validation = { + "software_installation_type": {"required": True}, + "bom_url": {"required": True}, + "sap_bits_storage_account_id": {"required": True}, + "software_version": {"required": True}, + } + + _attribute_map = { + "software_installation_type": {"key": "softwareInstallationType", "type": "str"}, + "bom_url": {"key": "bomUrl", "type": "str"}, + "sap_bits_storage_account_id": {"key": "sapBitsStorageAccountId", "type": "str"}, + "software_version": {"key": "softwareVersion", "type": "str"}, + "high_availability_software_configuration": { + "key": "highAvailabilitySoftwareConfiguration", + "type": "HighAvailabilitySoftwareConfiguration", + }, + } + + def __init__( + self, + *, + bom_url: str, + sap_bits_storage_account_id: str, + software_version: str, + high_availability_software_configuration: Optional["_models.HighAvailabilitySoftwareConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword bom_url: The URL to the SAP Build of Materials(BOM) file. Required. + :paramtype bom_url: str + :keyword sap_bits_storage_account_id: The SAP bits storage account id. Required. + :paramtype sap_bits_storage_account_id: str + :keyword software_version: The software version to install. Required. + :paramtype software_version: str + :keyword high_availability_software_configuration: Gets or sets the HA software configuration. + :paramtype high_availability_software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.HighAvailabilitySoftwareConfiguration + """ + super().__init__(**kwargs) + self.software_installation_type: str = "SAPInstallWithoutOSConfig" + self.bom_url = bom_url + self.sap_bits_storage_account_id = sap_bits_storage_account_id + self.software_version = software_version + self.high_availability_software_configuration = high_availability_software_configuration + + +class SAPSizingRecommendationRequest(_serialization.Model): + """The SAP Sizing Recommendation request. + + All required parameters must be populated in order to send to server. + + :ivar app_location: The geo-location where the resource is to be created. Required. + :vartype app_location: str + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :vartype environment: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". + :vartype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :ivar deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known values + are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar saps: The SAP Application Performance Standard measurement. Required. + :vartype saps: int + :ivar db_memory: The database memory configuration. Required. + :vartype db_memory: int + :ivar database_type: The database type. Required. Known values are: "HANA" and "DB2". + :vartype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :ivar db_scale_method: The DB scale method. "ScaleUp" + :vartype db_scale_method: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseScaleMethod + :ivar high_availability_type: The high availability type. Known values are: "AvailabilitySet" + and "AvailabilityZone". + :vartype high_availability_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPHighAvailabilityType + """ + + _validation = { + "app_location": {"required": True}, + "environment": {"required": True}, + "sap_product": {"required": True}, + "deployment_type": {"required": True}, + "saps": {"required": True}, + "db_memory": {"required": True}, + "database_type": {"required": True}, + } + + _attribute_map = { + "app_location": {"key": "appLocation", "type": "str"}, + "environment": {"key": "environment", "type": "str"}, + "sap_product": {"key": "sapProduct", "type": "str"}, + "deployment_type": {"key": "deploymentType", "type": "str"}, + "saps": {"key": "saps", "type": "int"}, + "db_memory": {"key": "dbMemory", "type": "int"}, + "database_type": {"key": "databaseType", "type": "str"}, + "db_scale_method": {"key": "dbScaleMethod", "type": "str"}, + "high_availability_type": {"key": "highAvailabilityType", "type": "str"}, + } + + def __init__( + self, + *, + app_location: str, + environment: Union[str, "_models.SAPEnvironmentType"], + sap_product: Union[str, "_models.SAPProductType"], + deployment_type: Union[str, "_models.SAPDeploymentType"], + saps: int, + db_memory: int, + database_type: Union[str, "_models.SAPDatabaseType"], + db_scale_method: Optional[Union[str, "_models.SAPDatabaseScaleMethod"]] = None, + high_availability_type: Optional[Union[str, "_models.SAPHighAvailabilityType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword app_location: The geo-location where the resource is to be created. Required. + :paramtype app_location: str + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :paramtype environment: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". + :paramtype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :keyword deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known + values are: "SingleServer" and "ThreeTier". + :paramtype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :keyword saps: The SAP Application Performance Standard measurement. Required. + :paramtype saps: int + :keyword db_memory: The database memory configuration. Required. + :paramtype db_memory: int + :keyword database_type: The database type. Required. Known values are: "HANA" and "DB2". + :paramtype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :keyword db_scale_method: The DB scale method. "ScaleUp" + :paramtype db_scale_method: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseScaleMethod + :keyword high_availability_type: The high availability type. Known values are: + "AvailabilitySet" and "AvailabilityZone". + :paramtype high_availability_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPHighAvailabilityType + """ + super().__init__(**kwargs) + self.app_location = app_location + self.environment = environment + self.sap_product = sap_product + self.deployment_type = deployment_type + self.saps = saps + self.db_memory = db_memory + self.database_type = database_type + self.db_scale_method = db_scale_method + self.high_availability_type = high_availability_type + + +class SAPSizingRecommendationResult(_serialization.Model): + """The SAP sizing recommendation result. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SingleServerRecommendationResult, ThreeTierRecommendationResult + + All required parameters must be populated in order to send to server. + + :ivar deployment_type: The type of SAP deployment, single server or Three tier. Required. Known + values are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + """ + + _validation = { + "deployment_type": {"required": True}, + } + + _attribute_map = { + "deployment_type": {"key": "deploymentType", "type": "str"}, + } + + _subtype_map = { + "deployment_type": { + "SingleServer": "SingleServerRecommendationResult", + "ThreeTier": "ThreeTierRecommendationResult", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.deployment_type: Optional[str] = None + + +class SAPSupportedResourceSkusResult(_serialization.Model): + """The list of supported SKUs for different resources which are part of SAP deployment. + + :ivar supported_skus: Gets the list of SAP supported SKUs. + :vartype supported_skus: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedSku] + """ + + _attribute_map = { + "supported_skus": {"key": "supportedSkus", "type": "[SAPSupportedSku]"}, + } + + def __init__(self, *, supported_skus: Optional[List["_models.SAPSupportedSku"]] = None, **kwargs: Any) -> None: + """ + :keyword supported_skus: Gets the list of SAP supported SKUs. + :paramtype supported_skus: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedSku] + """ + super().__init__(**kwargs) + self.supported_skus = supported_skus + + +class SAPSupportedSku(_serialization.Model): + """The SAP supported SKU. + + :ivar vm_sku: The VM Sku. + :vartype vm_sku: str + :ivar is_app_server_certified: True if the Sku is certified for App server in the SAP system. + :vartype is_app_server_certified: bool + :ivar is_database_certified: True if the Sku is certified for Database server in the SAP + system. + :vartype is_database_certified: bool + """ + + _attribute_map = { + "vm_sku": {"key": "vmSku", "type": "str"}, + "is_app_server_certified": {"key": "isAppServerCertified", "type": "bool"}, + "is_database_certified": {"key": "isDatabaseCertified", "type": "bool"}, + } + + def __init__( + self, + *, + vm_sku: Optional[str] = None, + is_app_server_certified: Optional[bool] = None, + is_database_certified: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_sku: The VM Sku. + :paramtype vm_sku: str + :keyword is_app_server_certified: True if the Sku is certified for App server in the SAP + system. + :paramtype is_app_server_certified: bool + :keyword is_database_certified: True if the Sku is certified for Database server in the SAP + system. + :paramtype is_database_certified: bool + """ + super().__init__(**kwargs) + self.vm_sku = vm_sku + self.is_app_server_certified = is_app_server_certified + self.is_database_certified = is_database_certified + + +class SAPSupportedSkusRequest(_serialization.Model): + """The SAP request to get list of supported SKUs. + + All required parameters must be populated in order to send to server. + + :ivar app_location: The geo-location where the resource is to be created. Required. + :vartype app_location: str + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :vartype environment: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". + :vartype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :ivar deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known values + are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: "HANA" + and "DB2". + :vartype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :ivar high_availability_type: The high availability type. Known values are: "AvailabilitySet" + and "AvailabilityZone". + :vartype high_availability_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPHighAvailabilityType + """ + + _validation = { + "app_location": {"required": True}, + "environment": {"required": True}, + "sap_product": {"required": True}, + "deployment_type": {"required": True}, + "database_type": {"required": True}, + } + + _attribute_map = { + "app_location": {"key": "appLocation", "type": "str"}, + "environment": {"key": "environment", "type": "str"}, + "sap_product": {"key": "sapProduct", "type": "str"}, + "deployment_type": {"key": "deploymentType", "type": "str"}, + "database_type": {"key": "databaseType", "type": "str"}, + "high_availability_type": {"key": "highAvailabilityType", "type": "str"}, + } + + def __init__( + self, + *, + app_location: str, + environment: Union[str, "_models.SAPEnvironmentType"], + sap_product: Union[str, "_models.SAPProductType"], + deployment_type: Union[str, "_models.SAPDeploymentType"], + database_type: Union[str, "_models.SAPDatabaseType"], + high_availability_type: Optional[Union[str, "_models.SAPHighAvailabilityType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword app_location: The geo-location where the resource is to be created. Required. + :paramtype app_location: str + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :paramtype environment: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". + :paramtype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :keyword deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known + values are: "SingleServer" and "ThreeTier". + :paramtype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :keyword database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: + "HANA" and "DB2". + :paramtype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :keyword high_availability_type: The high availability type. Known values are: + "AvailabilitySet" and "AvailabilityZone". + :paramtype high_availability_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPHighAvailabilityType + """ + super().__init__(**kwargs) + self.app_location = app_location + self.environment = environment + self.sap_product = sap_product + self.deployment_type = deployment_type + self.database_type = database_type + self.high_availability_type = high_availability_type + + +class SAPVirtualInstance(TrackedResource): + """Define the Virtual Instance for SAP solutions resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :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.workloadssapvirtualinstance.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar identity: Managed service identity (user assigned identities). + :vartype identity: ~azure.mgmt.workloadssapvirtualinstance.models.UserAssignedServiceIdentity + :ivar properties: Defines the Virtual Instance for SAP solutions resource properties. Required. + :vartype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "UserAssignedServiceIdentity"}, + "properties": {"key": "properties", "type": "SAPVirtualInstanceProperties"}, + } + + def __init__( + self, + *, + location: str, + properties: "_models.SAPVirtualInstanceProperties", + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: Managed service identity (user assigned identities). + :paramtype identity: ~azure.mgmt.workloadssapvirtualinstance.models.UserAssignedServiceIdentity + :keyword properties: Defines the Virtual Instance for SAP solutions resource properties. + Required. + :paramtype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.properties = properties + + +class SAPVirtualInstanceError(_serialization.Model): + """An error response from the Virtual Instance for SAP Workload service. + + :ivar properties: The Virtual Instance for SAP error body. + :vartype properties: ~azure.mgmt.workloadssapvirtualinstance.models.ErrorDefinition + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "ErrorDefinition"}, + } + + def __init__(self, *, properties: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The Virtual Instance for SAP error body. + :paramtype properties: ~azure.mgmt.workloadssapvirtualinstance.models.ErrorDefinition + """ + super().__init__(**kwargs) + self.properties = properties + + +class SAPVirtualInstanceList(_serialization.Model): + """Defines the collection of Virtual Instance for SAP solutions resources. + + :ivar value: Gets the list of Virtual Instances for SAP solutions resources. + :vartype value: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :ivar next_link: Gets the value of next link. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SAPVirtualInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SAPVirtualInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets the list of Virtual Instances for SAP solutions resources. + :paramtype value: list[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :keyword next_link: Gets the value of next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SAPVirtualInstanceProperties(_serialization.Model): + """Defines the Virtual Instance for SAP solutions resource 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 server. + + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :vartype environment: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". + :vartype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :ivar managed_resources_network_access_type: Specifies the network access configuration for the + resources that will be deployed in the Managed Resource Group. The options to choose from are + Public and Private. If 'Private' is chosen, the Storage Account service tag should be enabled + on the subnets in which the SAP VMs exist. This is required for establishing connectivity + between VM extensions and the managed resource group storage account. This setting is currently + applicable only to Storage Account. Learn more here + https://go.microsoft.com/fwlink/?linkid=2247228. Known values are: "Public" and "Private". + :vartype managed_resources_network_access_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedResourcesNetworkAccessType + :ivar configuration: Defines if the SAP system is being created using Azure Center for SAP + solutions (ACSS) or if an existing SAP system is being registered with ACSS. Required. + :vartype configuration: ~azure.mgmt.workloadssapvirtualinstance.models.SAPConfiguration + :ivar managed_resource_group_configuration: Managed resource group configuration. + :vartype managed_resource_group_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedRGConfiguration + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", "Unavailable", and "SoftShutdown". + :vartype status: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceStatus + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". + :vartype health: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPHealthState + :ivar state: Defines the Virtual Instance for SAP state. Known values are: + "InfrastructureDeploymentPending", "InfrastructureDeploymentInProgress", + "InfrastructureDeploymentFailed", "SoftwareInstallationPending", + "SoftwareInstallationInProgress", "SoftwareInstallationFailed", "SoftwareDetectionInProgress", + "SoftwareDetectionFailed", "DiscoveryPending", "DiscoveryInProgress", "DiscoveryFailed", + "RegistrationComplete", and "ACSSInstallationBlocked". + :vartype state: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceState + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SapVirtualInstanceProvisioningState + :ivar errors: Indicates any errors on the Virtual Instance for SAP solutions resource. + :vartype errors: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstanceError + """ + + _validation = { + "environment": {"required": True}, + "sap_product": {"required": True}, + "configuration": {"required": True}, + "status": {"readonly": True}, + "health": {"readonly": True}, + "state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, + } + + _attribute_map = { + "environment": {"key": "environment", "type": "str"}, + "sap_product": {"key": "sapProduct", "type": "str"}, + "managed_resources_network_access_type": {"key": "managedResourcesNetworkAccessType", "type": "str"}, + "configuration": {"key": "configuration", "type": "SAPConfiguration"}, + "managed_resource_group_configuration": { + "key": "managedResourceGroupConfiguration", + "type": "ManagedRGConfiguration", + }, + "status": {"key": "status", "type": "str"}, + "health": {"key": "health", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "errors": {"key": "errors", "type": "SAPVirtualInstanceError"}, + } + + def __init__( + self, + *, + environment: Union[str, "_models.SAPEnvironmentType"], + sap_product: Union[str, "_models.SAPProductType"], + configuration: "_models.SAPConfiguration", + managed_resources_network_access_type: Optional[Union[str, "_models.ManagedResourcesNetworkAccessType"]] = None, + managed_resource_group_configuration: Optional["_models.ManagedRGConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". + :paramtype environment: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPEnvironmentType + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". + :paramtype sap_product: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPProductType + :keyword managed_resources_network_access_type: Specifies the network access configuration for + the resources that will be deployed in the Managed Resource Group. The options to choose from + are Public and Private. If 'Private' is chosen, the Storage Account service tag should be + enabled on the subnets in which the SAP VMs exist. This is required for establishing + connectivity between VM extensions and the managed resource group storage account. This setting + is currently applicable only to Storage Account. Learn more here + https://go.microsoft.com/fwlink/?linkid=2247228. Known values are: "Public" and "Private". + :paramtype managed_resources_network_access_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedResourcesNetworkAccessType + :keyword configuration: Defines if the SAP system is being created using Azure Center for SAP + solutions (ACSS) or if an existing SAP system is being registered with ACSS. Required. + :paramtype configuration: ~azure.mgmt.workloadssapvirtualinstance.models.SAPConfiguration + :keyword managed_resource_group_configuration: Managed resource group configuration. + :paramtype managed_resource_group_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedRGConfiguration + """ + super().__init__(**kwargs) + self.environment = environment + self.sap_product = sap_product + self.managed_resources_network_access_type = managed_resources_network_access_type + self.configuration = configuration + self.managed_resource_group_configuration = managed_resource_group_configuration + self.status = None + self.health = None + self.state = None + self.provisioning_state = None + self.errors = None + + +class ServiceInitiatedSoftwareConfiguration(SoftwareConfiguration): + """The SAP Software configuration Input when the software is to be installed by service. + + All required parameters must be populated in order to send to server. + + :ivar software_installation_type: The SAP software installation Type. Required. Known values + are: "ServiceInitiated", "SAPInstallWithoutOSConfig", and "External". + :vartype software_installation_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSoftwareInstallationType + :ivar bom_url: The URL to the SAP Build of Materials(BOM) file. Required. + :vartype bom_url: str + :ivar software_version: The software version to install. Required. + :vartype software_version: str + :ivar sap_bits_storage_account_id: The SAP bits storage account id. Required. + :vartype sap_bits_storage_account_id: str + :ivar sap_fqdn: The FQDN to set for the SAP system during install. Required. + :vartype sap_fqdn: str + :ivar ssh_private_key: The SSH private key. Required. + :vartype ssh_private_key: str + :ivar high_availability_software_configuration: Gets or sets the HA software configuration. + :vartype high_availability_software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.HighAvailabilitySoftwareConfiguration + """ + + _validation = { + "software_installation_type": {"required": True}, + "bom_url": {"required": True}, + "software_version": {"required": True}, + "sap_bits_storage_account_id": {"required": True}, + "sap_fqdn": {"required": True}, + "ssh_private_key": {"required": True}, + } + + _attribute_map = { + "software_installation_type": {"key": "softwareInstallationType", "type": "str"}, + "bom_url": {"key": "bomUrl", "type": "str"}, + "software_version": {"key": "softwareVersion", "type": "str"}, + "sap_bits_storage_account_id": {"key": "sapBitsStorageAccountId", "type": "str"}, + "sap_fqdn": {"key": "sapFqdn", "type": "str"}, + "ssh_private_key": {"key": "sshPrivateKey", "type": "str"}, + "high_availability_software_configuration": { + "key": "highAvailabilitySoftwareConfiguration", + "type": "HighAvailabilitySoftwareConfiguration", + }, + } + + def __init__( + self, + *, + bom_url: str, + software_version: str, + sap_bits_storage_account_id: str, + sap_fqdn: str, + ssh_private_key: str, + high_availability_software_configuration: Optional["_models.HighAvailabilitySoftwareConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword bom_url: The URL to the SAP Build of Materials(BOM) file. Required. + :paramtype bom_url: str + :keyword software_version: The software version to install. Required. + :paramtype software_version: str + :keyword sap_bits_storage_account_id: The SAP bits storage account id. Required. + :paramtype sap_bits_storage_account_id: str + :keyword sap_fqdn: The FQDN to set for the SAP system during install. Required. + :paramtype sap_fqdn: str + :keyword ssh_private_key: The SSH private key. Required. + :paramtype ssh_private_key: str + :keyword high_availability_software_configuration: Gets or sets the HA software configuration. + :paramtype high_availability_software_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.HighAvailabilitySoftwareConfiguration + """ + super().__init__(**kwargs) + self.software_installation_type: str = "ServiceInitiated" + self.bom_url = bom_url + self.software_version = software_version + self.sap_bits_storage_account_id = sap_bits_storage_account_id + self.sap_fqdn = sap_fqdn + self.ssh_private_key = ssh_private_key + self.high_availability_software_configuration = high_availability_software_configuration + + +class SharedStorageResourceNames(_serialization.Model): + """The resource names object for shared storage. + + :ivar shared_storage_account_name: The full name of the shared storage account. If it is not + provided, it will be defaulted to {SID}nfs{guid of 15 chars}. + :vartype shared_storage_account_name: str + :ivar shared_storage_account_private_end_point_name: The full name of private end point for the + shared storage account. If it is not provided, it will be defaulted to {storageAccountName}_pe. + :vartype shared_storage_account_private_end_point_name: str + """ + + _attribute_map = { + "shared_storage_account_name": {"key": "sharedStorageAccountName", "type": "str"}, + "shared_storage_account_private_end_point_name": { + "key": "sharedStorageAccountPrivateEndPointName", + "type": "str", + }, + } + + def __init__( + self, + *, + shared_storage_account_name: Optional[str] = None, + shared_storage_account_private_end_point_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword shared_storage_account_name: The full name of the shared storage account. If it is not + provided, it will be defaulted to {SID}nfs{guid of 15 chars}. + :paramtype shared_storage_account_name: str + :keyword shared_storage_account_private_end_point_name: The full name of private end point for + the shared storage account. If it is not provided, it will be defaulted to + {storageAccountName}_pe. + :paramtype shared_storage_account_private_end_point_name: str + """ + super().__init__(**kwargs) + self.shared_storage_account_name = shared_storage_account_name + self.shared_storage_account_private_end_point_name = shared_storage_account_private_end_point_name + + +class SingleServerConfiguration(InfrastructureConfiguration): + """Gets or sets the single server configuration. For prerequisites for creating the + infrastructure, please see `here + `_. + + All required parameters must be populated in order to send to server. + + :ivar deployment_type: The type of SAP deployment, single server or Three tier. Required. Known + values are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar app_resource_group: The application resource group where SAP system resources will be + deployed. Required. + :vartype app_resource_group: str + :ivar network_configuration: Network configuration for the server. + :vartype network_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.NetworkConfiguration + :ivar database_type: The database type. Known values are: "HANA" and "DB2". + :vartype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :ivar subnet_id: The subnet id. Required. + :vartype subnet_id: str + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. + :vartype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :ivar db_disk_configuration: Gets or sets the disk configuration. + :vartype db_disk_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.DiskConfiguration + :ivar custom_resource_names: The set of custom names to be used for underlying azure resources + that are part of the SAP system. + :vartype custom_resource_names: + ~azure.mgmt.workloadssapvirtualinstance.models.SingleServerCustomResourceNames + """ + + _validation = { + "deployment_type": {"required": True}, + "app_resource_group": {"required": True}, + "subnet_id": {"required": True}, + "virtual_machine_configuration": {"required": True}, + } + + _attribute_map = { + "deployment_type": {"key": "deploymentType", "type": "str"}, + "app_resource_group": {"key": "appResourceGroup", "type": "str"}, + "network_configuration": {"key": "networkConfiguration", "type": "NetworkConfiguration"}, + "database_type": {"key": "databaseType", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "virtual_machine_configuration": {"key": "virtualMachineConfiguration", "type": "VirtualMachineConfiguration"}, + "db_disk_configuration": {"key": "dbDiskConfiguration", "type": "DiskConfiguration"}, + "custom_resource_names": {"key": "customResourceNames", "type": "SingleServerCustomResourceNames"}, + } + + def __init__( + self, + *, + app_resource_group: str, + subnet_id: str, + virtual_machine_configuration: "_models.VirtualMachineConfiguration", + network_configuration: Optional["_models.NetworkConfiguration"] = None, + database_type: Optional[Union[str, "_models.SAPDatabaseType"]] = None, + db_disk_configuration: Optional["_models.DiskConfiguration"] = None, + custom_resource_names: Optional["_models.SingleServerCustomResourceNames"] = None, + **kwargs: Any + ) -> None: + """ + :keyword app_resource_group: The application resource group where SAP system resources will be + deployed. Required. + :paramtype app_resource_group: str + :keyword network_configuration: Network configuration for the server. + :paramtype network_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.NetworkConfiguration + :keyword database_type: The database type. Known values are: "HANA" and "DB2". + :paramtype database_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseType + :keyword subnet_id: The subnet id. Required. + :paramtype subnet_id: str + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. + :paramtype virtual_machine_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineConfiguration + :keyword db_disk_configuration: Gets or sets the disk configuration. + :paramtype db_disk_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.DiskConfiguration + :keyword custom_resource_names: The set of custom names to be used for underlying azure + resources that are part of the SAP system. + :paramtype custom_resource_names: + ~azure.mgmt.workloadssapvirtualinstance.models.SingleServerCustomResourceNames + """ + super().__init__(app_resource_group=app_resource_group, **kwargs) + self.deployment_type: str = "SingleServer" + self.network_configuration = network_configuration + self.database_type = database_type + self.subnet_id = subnet_id + self.virtual_machine_configuration = virtual_machine_configuration + self.db_disk_configuration = db_disk_configuration + self.custom_resource_names = custom_resource_names + + +class SingleServerCustomResourceNames(_serialization.Model): + """The resource-names input to specify custom names for underlying azure resources that are part + of a single server SAP system. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SingleServerFullResourceNames + + All required parameters must be populated in order to send to server. + + :ivar naming_pattern_type: The pattern type to be used for resource naming. Required. + "FullResourceName" + :vartype naming_pattern_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.NamingPatternType + """ + + _validation = { + "naming_pattern_type": {"required": True}, + } + + _attribute_map = { + "naming_pattern_type": {"key": "namingPatternType", "type": "str"}, + } + + _subtype_map = {"naming_pattern_type": {"FullResourceName": "SingleServerFullResourceNames"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.naming_pattern_type: Optional[str] = None + + +class SingleServerFullResourceNames(SingleServerCustomResourceNames): + """The resource name object where the specified values will be full resource names of the + corresponding resources in a single server SAP system. + + All required parameters must be populated in order to send to server. + + :ivar naming_pattern_type: The pattern type to be used for resource naming. Required. + "FullResourceName" + :vartype naming_pattern_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.NamingPatternType + :ivar virtual_machine: The resource names object for virtual machine and related resources. + :vartype virtual_machine: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames + """ + + _validation = { + "naming_pattern_type": {"required": True}, + } + + _attribute_map = { + "naming_pattern_type": {"key": "namingPatternType", "type": "str"}, + "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineResourceNames"}, + } + + def __init__( + self, *, virtual_machine: Optional["_models.VirtualMachineResourceNames"] = None, **kwargs: Any + ) -> None: + """ + :keyword virtual_machine: The resource names object for virtual machine and related resources. + :paramtype virtual_machine: + ~azure.mgmt.workloadssapvirtualinstance.models.VirtualMachineResourceNames + """ + super().__init__(**kwargs) + self.naming_pattern_type: str = "FullResourceName" + self.virtual_machine = virtual_machine + + +class SingleServerRecommendationResult(SAPSizingRecommendationResult): + """The recommended configuration for a single server SAP system. + + All required parameters must be populated in order to send to server. + + :ivar deployment_type: The type of SAP deployment, single server or Three tier. Required. Known + values are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar vm_sku: The recommended VM SKU for single server. + :vartype vm_sku: str + """ + + _validation = { + "deployment_type": {"required": True}, + } + + _attribute_map = { + "deployment_type": {"key": "deploymentType", "type": "str"}, + "vm_sku": {"key": "vmSku", "type": "str"}, + } + + def __init__(self, *, vm_sku: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword vm_sku: The recommended VM SKU for single server. + :paramtype vm_sku: str + """ + super().__init__(**kwargs) + self.deployment_type: str = "SingleServer" + self.vm_sku = vm_sku + + +class SkipFileShareConfiguration(FileShareConfiguration): + """Gets or sets the file share configuration for scenarios where transport directory fileshare is + not created or required. + + All required parameters must be populated in order to send to server. + + :ivar configuration_type: The type of file share config. Required. Known values are: "Skip", + "CreateAndMount", and "Mount". + :vartype configuration_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ConfigurationType + """ + + _validation = { + "configuration_type": {"required": True}, + } + + _attribute_map = { + "configuration_type": {"key": "configurationType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.configuration_type: str = "Skip" + + +class SshConfiguration(_serialization.Model): + """SSH configuration for Linux based VMs running on Azure. + + :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. + :vartype public_keys: list[~azure.mgmt.workloadssapvirtualinstance.models.SshPublicKey] + """ + + _attribute_map = { + "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, + } + + def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: + """ + :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. + :paramtype public_keys: list[~azure.mgmt.workloadssapvirtualinstance.models.SshPublicKey] + """ + super().__init__(**kwargs) + self.public_keys = public_keys + + +class SshKeyPair(_serialization.Model): + """The SSH Key-pair used to authenticate with the VM. The key needs to be at least 2048-bit and in + ssh-rsa format. :code:`
`:code:`
` For creating ssh keys, see `Create SSH keys on Linux + and Mac for Linux VMs in Azure + `_. + + :ivar public_key: SSH public key. + :vartype public_key: str + :ivar private_key: SSH private key. + :vartype private_key: str + """ + + _attribute_map = { + "public_key": {"key": "publicKey", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + } + + def __init__(self, *, public_key: Optional[str] = None, private_key: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword public_key: SSH public key. + :paramtype public_key: str + :keyword private_key: SSH private key. + :paramtype private_key: str + """ + super().__init__(**kwargs) + self.public_key = public_key + self.private_key = private_key + + +class SshPublicKey(_serialization.Model): + """Contains information about SSH certificate public key and the path on the Linux VM where the + public key is placed. + + :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The + key needs to be at least 2048-bit and in ssh-rsa format. :code:`
`:code:`
` For creating + ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure + `_. + :vartype key_data: str + """ + + _attribute_map = { + "key_data": {"key": "keyData", "type": "str"}, + } + + def __init__(self, *, key_data: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The + key needs to be at least 2048-bit and in ssh-rsa format. :code:`
`:code:`
` For creating + ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure + `_. + :paramtype key_data: str + """ + super().__init__(**kwargs) + self.key_data = key_data + + +class StartRequest(_serialization.Model): + """Start SAP instance(s) request body. + + :ivar start_vm: The boolean value indicates whether to start the virtual machines before + starting the SAP instances. + :vartype start_vm: bool + """ + + _attribute_map = { + "start_vm": {"key": "startVm", "type": "bool"}, + } + + def __init__(self, *, start_vm: bool = False, **kwargs: Any) -> None: + """ + :keyword start_vm: The boolean value indicates whether to start the virtual machines before + starting the SAP instances. + :paramtype start_vm: bool + """ + super().__init__(**kwargs) + self.start_vm = start_vm + + +class StopRequest(_serialization.Model): + """Stop SAP instance(s) request body. + + :ivar soft_stop_timeout_seconds: This parameter defines how long (in seconds) the soft shutdown + waits until the RFC/HTTP clients no longer consider the server for calls with load balancing. + Value 0 means that the kernel does not wait, but goes directly into the next shutdown state, + i.e. hard stop. + :vartype soft_stop_timeout_seconds: int + :ivar deallocate_vm: The boolean value indicates whether to Stop and deallocate the virtual + machines along with the SAP instances. + :vartype deallocate_vm: bool + """ + + _attribute_map = { + "soft_stop_timeout_seconds": {"key": "softStopTimeoutSeconds", "type": "int"}, + "deallocate_vm": {"key": "deallocateVm", "type": "bool"}, + } + + def __init__(self, *, soft_stop_timeout_seconds: int = 0, deallocate_vm: bool = False, **kwargs: Any) -> None: + """ + :keyword soft_stop_timeout_seconds: This parameter defines how long (in seconds) the soft + shutdown waits until the RFC/HTTP clients no longer consider the server for calls with load + balancing. Value 0 means that the kernel does not wait, but goes directly into the next + shutdown state, i.e. hard stop. + :paramtype soft_stop_timeout_seconds: int + :keyword deallocate_vm: The boolean value indicates whether to Stop and deallocate the virtual + machines along with the SAP instances. + :paramtype deallocate_vm: bool + """ + super().__init__(**kwargs) + self.soft_stop_timeout_seconds = soft_stop_timeout_seconds + self.deallocate_vm = deallocate_vm + + +class StorageConfiguration(_serialization.Model): + """Gets or sets the storage configuration. + + :ivar transport_file_share_configuration: The properties of the transport directory attached to + the VIS. The default for transportFileShareConfiguration is the createAndMount flow if storage + configuration is missing. + :vartype transport_file_share_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.FileShareConfiguration + """ + + _attribute_map = { + "transport_file_share_configuration": { + "key": "transportFileShareConfiguration", + "type": "FileShareConfiguration", + }, + } + + def __init__( + self, *, transport_file_share_configuration: Optional["_models.FileShareConfiguration"] = None, **kwargs: Any + ) -> None: + """ + :keyword transport_file_share_configuration: The properties of the transport directory attached + to the VIS. The default for transportFileShareConfiguration is the createAndMount flow if + storage configuration is missing. + :paramtype transport_file_share_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.FileShareConfiguration + """ + super().__init__(**kwargs) + self.transport_file_share_configuration = transport_file_share_configuration + + +class StorageInformation(_serialization.Model): + """Storage details of all the Storage accounts attached to the VM. For e.g. NFS on AFS Shared + Storage. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class ThreeTierConfiguration(InfrastructureConfiguration): + """Gets or sets the three tier SAP configuration. For prerequisites for creating the + infrastructure, please see `here + `_. + + All required parameters must be populated in order to send to server. + + :ivar deployment_type: The type of SAP deployment, single server or Three tier. Required. Known + values are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar app_resource_group: The application resource group where SAP system resources will be + deployed. Required. + :vartype app_resource_group: str + :ivar network_configuration: Network configuration common to all servers. + :vartype network_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.NetworkConfiguration + :ivar central_server: The central server configuration. Required. + :vartype central_server: + ~azure.mgmt.workloadssapvirtualinstance.models.CentralServerConfiguration + :ivar application_server: The application server configuration. Required. + :vartype application_server: + ~azure.mgmt.workloadssapvirtualinstance.models.ApplicationServerConfiguration + :ivar database_server: The database configuration. Required. + :vartype database_server: ~azure.mgmt.workloadssapvirtualinstance.models.DatabaseConfiguration + :ivar high_availability_config: The high availability configuration. + :vartype high_availability_config: + ~azure.mgmt.workloadssapvirtualinstance.models.HighAvailabilityConfiguration + :ivar storage_configuration: The storage configuration. + :vartype storage_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.StorageConfiguration + :ivar custom_resource_names: The set of custom names to be used for underlying azure resources + that are part of the SAP system. + :vartype custom_resource_names: + ~azure.mgmt.workloadssapvirtualinstance.models.ThreeTierCustomResourceNames + """ + + _validation = { + "deployment_type": {"required": True}, + "app_resource_group": {"required": True}, + "central_server": {"required": True}, + "application_server": {"required": True}, + "database_server": {"required": True}, + } + + _attribute_map = { + "deployment_type": {"key": "deploymentType", "type": "str"}, + "app_resource_group": {"key": "appResourceGroup", "type": "str"}, + "network_configuration": {"key": "networkConfiguration", "type": "NetworkConfiguration"}, + "central_server": {"key": "centralServer", "type": "CentralServerConfiguration"}, + "application_server": {"key": "applicationServer", "type": "ApplicationServerConfiguration"}, + "database_server": {"key": "databaseServer", "type": "DatabaseConfiguration"}, + "high_availability_config": {"key": "highAvailabilityConfig", "type": "HighAvailabilityConfiguration"}, + "storage_configuration": {"key": "storageConfiguration", "type": "StorageConfiguration"}, + "custom_resource_names": {"key": "customResourceNames", "type": "ThreeTierCustomResourceNames"}, + } + + def __init__( + self, + *, + app_resource_group: str, + central_server: "_models.CentralServerConfiguration", + application_server: "_models.ApplicationServerConfiguration", + database_server: "_models.DatabaseConfiguration", + network_configuration: Optional["_models.NetworkConfiguration"] = None, + high_availability_config: Optional["_models.HighAvailabilityConfiguration"] = None, + storage_configuration: Optional["_models.StorageConfiguration"] = None, + custom_resource_names: Optional["_models.ThreeTierCustomResourceNames"] = None, + **kwargs: Any + ) -> None: + """ + :keyword app_resource_group: The application resource group where SAP system resources will be + deployed. Required. + :paramtype app_resource_group: str + :keyword network_configuration: Network configuration common to all servers. + :paramtype network_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.NetworkConfiguration + :keyword central_server: The central server configuration. Required. + :paramtype central_server: + ~azure.mgmt.workloadssapvirtualinstance.models.CentralServerConfiguration + :keyword application_server: The application server configuration. Required. + :paramtype application_server: + ~azure.mgmt.workloadssapvirtualinstance.models.ApplicationServerConfiguration + :keyword database_server: The database configuration. Required. + :paramtype database_server: + ~azure.mgmt.workloadssapvirtualinstance.models.DatabaseConfiguration + :keyword high_availability_config: The high availability configuration. + :paramtype high_availability_config: + ~azure.mgmt.workloadssapvirtualinstance.models.HighAvailabilityConfiguration + :keyword storage_configuration: The storage configuration. + :paramtype storage_configuration: + ~azure.mgmt.workloadssapvirtualinstance.models.StorageConfiguration + :keyword custom_resource_names: The set of custom names to be used for underlying azure + resources that are part of the SAP system. + :paramtype custom_resource_names: + ~azure.mgmt.workloadssapvirtualinstance.models.ThreeTierCustomResourceNames + """ + super().__init__(app_resource_group=app_resource_group, **kwargs) + self.deployment_type: str = "ThreeTier" + self.network_configuration = network_configuration + self.central_server = central_server + self.application_server = application_server + self.database_server = database_server + self.high_availability_config = high_availability_config + self.storage_configuration = storage_configuration + self.custom_resource_names = custom_resource_names + + +class ThreeTierCustomResourceNames(_serialization.Model): + """The resource-names input to specify custom names for underlying azure resources that are part + of a three tier SAP system. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ThreeTierFullResourceNames + + All required parameters must be populated in order to send to server. + + :ivar naming_pattern_type: The pattern type to be used for resource naming. Required. + "FullResourceName" + :vartype naming_pattern_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.NamingPatternType + """ + + _validation = { + "naming_pattern_type": {"required": True}, + } + + _attribute_map = { + "naming_pattern_type": {"key": "namingPatternType", "type": "str"}, + } + + _subtype_map = {"naming_pattern_type": {"FullResourceName": "ThreeTierFullResourceNames"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.naming_pattern_type: Optional[str] = None + + +class ThreeTierFullResourceNames(ThreeTierCustomResourceNames): + """The resource name object where the specified values will be full resource names of the + corresponding resources in a three tier SAP system. + + All required parameters must be populated in order to send to server. + + :ivar naming_pattern_type: The pattern type to be used for resource naming. Required. + "FullResourceName" + :vartype naming_pattern_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.NamingPatternType + :ivar central_server: The full resource names object for central server layer resources. + :vartype central_server: + ~azure.mgmt.workloadssapvirtualinstance.models.CentralServerFullResourceNames + :ivar application_server: The full resource names object for application layer resources. The + number of entries in this list should be equal to the number VMs to be created for application + layer. + :vartype application_server: + ~azure.mgmt.workloadssapvirtualinstance.models.ApplicationServerFullResourceNames + :ivar database_server: The full resource names object for database layer resources. The number + of entries in this list should be equal to the number VMs to be created for database layer. + :vartype database_server: + ~azure.mgmt.workloadssapvirtualinstance.models.DatabaseServerFullResourceNames + :ivar shared_storage: The resource names object for shared storage. + :vartype shared_storage: + ~azure.mgmt.workloadssapvirtualinstance.models.SharedStorageResourceNames + """ + + _validation = { + "naming_pattern_type": {"required": True}, + } + + _attribute_map = { + "naming_pattern_type": {"key": "namingPatternType", "type": "str"}, + "central_server": {"key": "centralServer", "type": "CentralServerFullResourceNames"}, + "application_server": {"key": "applicationServer", "type": "ApplicationServerFullResourceNames"}, + "database_server": {"key": "databaseServer", "type": "DatabaseServerFullResourceNames"}, + "shared_storage": {"key": "sharedStorage", "type": "SharedStorageResourceNames"}, + } + + def __init__( + self, + *, + central_server: Optional["_models.CentralServerFullResourceNames"] = None, + application_server: Optional["_models.ApplicationServerFullResourceNames"] = None, + database_server: Optional["_models.DatabaseServerFullResourceNames"] = None, + shared_storage: Optional["_models.SharedStorageResourceNames"] = None, + **kwargs: Any + ) -> None: + """ + :keyword central_server: The full resource names object for central server layer resources. + :paramtype central_server: + ~azure.mgmt.workloadssapvirtualinstance.models.CentralServerFullResourceNames + :keyword application_server: The full resource names object for application layer resources. + The number of entries in this list should be equal to the number VMs to be created for + application layer. + :paramtype application_server: + ~azure.mgmt.workloadssapvirtualinstance.models.ApplicationServerFullResourceNames + :keyword database_server: The full resource names object for database layer resources. The + number of entries in this list should be equal to the number VMs to be created for database + layer. + :paramtype database_server: + ~azure.mgmt.workloadssapvirtualinstance.models.DatabaseServerFullResourceNames + :keyword shared_storage: The resource names object for shared storage. + :paramtype shared_storage: + ~azure.mgmt.workloadssapvirtualinstance.models.SharedStorageResourceNames + """ + super().__init__(**kwargs) + self.naming_pattern_type: str = "FullResourceName" + self.central_server = central_server + self.application_server = application_server + self.database_server = database_server + self.shared_storage = shared_storage + + +class ThreeTierRecommendationResult(SAPSizingRecommendationResult): + """The recommended configuration for a three tier SAP system. + + All required parameters must be populated in order to send to server. + + :ivar deployment_type: The type of SAP deployment, single server or Three tier. Required. Known + values are: "SingleServer" and "ThreeTier". + :vartype deployment_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDeploymentType + :ivar db_vm_sku: The database VM SKU. + :vartype db_vm_sku: str + :ivar database_instance_count: The database server instance count. + :vartype database_instance_count: int + :ivar central_server_vm_sku: The central server VM SKU. + :vartype central_server_vm_sku: str + :ivar central_server_instance_count: The central server instance count. + :vartype central_server_instance_count: int + :ivar application_server_vm_sku: The application server VM SKU. + :vartype application_server_vm_sku: str + :ivar application_server_instance_count: The application server instance count. + :vartype application_server_instance_count: int + """ + + _validation = { + "deployment_type": {"required": True}, + } + + _attribute_map = { + "deployment_type": {"key": "deploymentType", "type": "str"}, + "db_vm_sku": {"key": "dbVmSku", "type": "str"}, + "database_instance_count": {"key": "databaseInstanceCount", "type": "int"}, + "central_server_vm_sku": {"key": "centralServerVmSku", "type": "str"}, + "central_server_instance_count": {"key": "centralServerInstanceCount", "type": "int"}, + "application_server_vm_sku": {"key": "applicationServerVmSku", "type": "str"}, + "application_server_instance_count": {"key": "applicationServerInstanceCount", "type": "int"}, + } + + def __init__( + self, + *, + db_vm_sku: Optional[str] = None, + database_instance_count: Optional[int] = None, + central_server_vm_sku: Optional[str] = None, + central_server_instance_count: Optional[int] = None, + application_server_vm_sku: Optional[str] = None, + application_server_instance_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword db_vm_sku: The database VM SKU. + :paramtype db_vm_sku: str + :keyword database_instance_count: The database server instance count. + :paramtype database_instance_count: int + :keyword central_server_vm_sku: The central server VM SKU. + :paramtype central_server_vm_sku: str + :keyword central_server_instance_count: The central server instance count. + :paramtype central_server_instance_count: int + :keyword application_server_vm_sku: The application server VM SKU. + :paramtype application_server_vm_sku: str + :keyword application_server_instance_count: The application server instance count. + :paramtype application_server_instance_count: int + """ + super().__init__(**kwargs) + self.deployment_type: str = "ThreeTier" + self.db_vm_sku = db_vm_sku + self.database_instance_count = database_instance_count + self.central_server_vm_sku = central_server_vm_sku + self.central_server_instance_count = central_server_instance_count + self.application_server_vm_sku = application_server_vm_sku + self.application_server_instance_count = application_server_instance_count + + +class UpdateSAPApplicationInstanceRequest(_serialization.Model): + """Defines the request body for updating SAP Application Instance. + + :ivar tags: Gets or sets the Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class UpdateSAPCentralInstanceRequest(_serialization.Model): + """Defines the request body for updating SAP Central Instance. + + :ivar tags: Gets or sets the Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class UpdateSAPDatabaseInstanceRequest(_serialization.Model): + """Defines the request body for updating SAP Database Instance. + + :ivar tags: Gets or sets the Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class UpdateSAPVirtualInstanceProperties(_serialization.Model): + """Defines the properties to be updated for Virtual Instance for SAP. + + :ivar managed_resources_network_access_type: Specifies the network access configuration for the + resources that will be deployed in the Managed Resource Group. The options to choose from are + Public and Private. If 'Private' is chosen, the Storage Account service tag should be enabled + on the subnets in which the SAP VMs exist. This is required for establishing connectivity + between VM extensions and the managed resource group storage account. This setting is currently + applicable only to Storage Account. Learn more here + https://go.microsoft.com/fwlink/?linkid=2247228. Known values are: "Public" and "Private". + :vartype managed_resources_network_access_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedResourcesNetworkAccessType + """ + + _attribute_map = { + "managed_resources_network_access_type": {"key": "managedResourcesNetworkAccessType", "type": "str"}, + } + + def __init__( + self, + *, + managed_resources_network_access_type: Optional[Union[str, "_models.ManagedResourcesNetworkAccessType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword managed_resources_network_access_type: Specifies the network access configuration for + the resources that will be deployed in the Managed Resource Group. The options to choose from + are Public and Private. If 'Private' is chosen, the Storage Account service tag should be + enabled on the subnets in which the SAP VMs exist. This is required for establishing + connectivity between VM extensions and the managed resource group storage account. This setting + is currently applicable only to Storage Account. Learn more here + https://go.microsoft.com/fwlink/?linkid=2247228. Known values are: "Public" and "Private". + :paramtype managed_resources_network_access_type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedResourcesNetworkAccessType + """ + super().__init__(**kwargs) + self.managed_resources_network_access_type = managed_resources_network_access_type + + +class UpdateSAPVirtualInstanceRequest(_serialization.Model): + """Defines the request body for updating Virtual Instance for SAP. + + :ivar tags: Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar identity: Managed service identity (user assigned identities). + :vartype identity: ~azure.mgmt.workloadssapvirtualinstance.models.UserAssignedServiceIdentity + :ivar properties: Defines the properties to be updated for Virtual Instance for SAP. + :vartype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPVirtualInstanceProperties + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "UserAssignedServiceIdentity"}, + "properties": {"key": "properties", "type": "UpdateSAPVirtualInstanceProperties"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, + properties: Optional["_models.UpdateSAPVirtualInstanceProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: Managed service identity (user assigned identities). + :paramtype identity: ~azure.mgmt.workloadssapvirtualinstance.models.UserAssignedServiceIdentity + :keyword properties: Defines the properties to be updated for Virtual Instance for SAP. + :paramtype properties: + ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPVirtualInstanceProperties + """ + super().__init__(**kwargs) + self.tags = tags + self.identity = identity + self.properties = properties + + +class UserAssignedIdentity(_serialization.Model): + """User assigned identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class UserAssignedServiceIdentity(_serialization.Model): + """Managed service identity (user assigned identities). + + All required parameters must be populated in order to send to server. + + :ivar type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". + :vartype type: str or ~azure.mgmt.workloadssapvirtualinstance.models.ManagedServiceIdentityType + :ivar user_assigned_identities: User assigned identities dictionary. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.workloadssapvirtualinstance.models.UserAssignedIdentity] + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". + :paramtype type: str or + ~azure.mgmt.workloadssapvirtualinstance.models.ManagedServiceIdentityType + :keyword user_assigned_identities: User assigned identities dictionary. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.workloadssapvirtualinstance.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class VirtualMachineConfiguration(_serialization.Model): + """Defines the virtual machine configuration. + + All required parameters must be populated in order to send to server. + + :ivar vm_size: The virtual machine size. Required. + :vartype vm_size: str + :ivar image_reference: The image reference. Required. + :vartype image_reference: ~azure.mgmt.workloadssapvirtualinstance.models.ImageReference + :ivar os_profile: The OS profile. Required. + :vartype os_profile: ~azure.mgmt.workloadssapvirtualinstance.models.OSProfile + """ + + _validation = { + "vm_size": {"required": True}, + "image_reference": {"required": True}, + "os_profile": {"required": True}, + } + + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "image_reference": {"key": "imageReference", "type": "ImageReference"}, + "os_profile": {"key": "osProfile", "type": "OSProfile"}, + } + + def __init__( + self, *, vm_size: str, image_reference: "_models.ImageReference", os_profile: "_models.OSProfile", **kwargs: Any + ) -> None: + """ + :keyword vm_size: The virtual machine size. Required. + :paramtype vm_size: str + :keyword image_reference: The image reference. Required. + :paramtype image_reference: ~azure.mgmt.workloadssapvirtualinstance.models.ImageReference + :keyword os_profile: The OS profile. Required. + :paramtype os_profile: ~azure.mgmt.workloadssapvirtualinstance.models.OSProfile + """ + super().__init__(**kwargs) + self.vm_size = vm_size + self.image_reference = image_reference + self.os_profile = os_profile + + +class VirtualMachineResourceNames(_serialization.Model): + """The resource names object for virtual machine and related resources. + + :ivar vm_name: The full name for virtual machine. The length of this field can be upto 64 + characters. If name is not provided, service uses a default name based on the deployment type. + For SingleServer, default name is {SID}vm. In case of HA-AvZone systems, default name will be + {SID}{app/ascs/db}z{a/b}vm with an incrementor at the end in case of more than 1 vm per layer. + For distributed and HA-AvSet systems, default name will be {SID}{app/ascs/db}vm with an + incrementor at the end in case of more than 1 vm per layer. + :vartype vm_name: str + :ivar host_name: The full name for virtual-machine's host (computer name). Currently, ACSS only + supports host names which are less than or equal to 13 characters long. If this value is not + provided, vmName will be used as host name. + :vartype host_name: str + :ivar network_interfaces: The list of network interface name objects for the selected virtual + machine. Currently, only one network interface is supported per virtual machine. + :vartype network_interfaces: + list[~azure.mgmt.workloadssapvirtualinstance.models.NetworkInterfaceResourceNames] + :ivar os_disk_name: The full name for OS disk attached to the VM. If this value is not + provided, it will be named by ARM as per its default naming standards (prefixed with vm name). + There is only one OS disk attached per Virtual Machine. + :vartype os_disk_name: str + :ivar data_disk_names: The full resource names for virtual machine data disks. This is a + dictionary containing list of names of data disks per volume. Currently supported volumes for + database layer are ['hana/data', 'hana/log', hana/shared', 'usr/sap', 'os', 'backup']. For + application and cs layers, only 'default' volume is supported. + :vartype data_disk_names: dict[str, list[str]] + """ + + _validation = { + "network_interfaces": {"max_items": 1, "min_items": 0}, + } + + _attribute_map = { + "vm_name": {"key": "vmName", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceResourceNames]"}, + "os_disk_name": {"key": "osDiskName", "type": "str"}, + "data_disk_names": {"key": "dataDiskNames", "type": "{[str]}"}, + } + + def __init__( + self, + *, + vm_name: Optional[str] = None, + host_name: Optional[str] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceResourceNames"]] = None, + os_disk_name: Optional[str] = None, + data_disk_names: Optional[Dict[str, List[str]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_name: The full name for virtual machine. The length of this field can be upto 64 + characters. If name is not provided, service uses a default name based on the deployment type. + For SingleServer, default name is {SID}vm. In case of HA-AvZone systems, default name will be + {SID}{app/ascs/db}z{a/b}vm with an incrementor at the end in case of more than 1 vm per layer. + For distributed and HA-AvSet systems, default name will be {SID}{app/ascs/db}vm with an + incrementor at the end in case of more than 1 vm per layer. + :paramtype vm_name: str + :keyword host_name: The full name for virtual-machine's host (computer name). Currently, ACSS + only supports host names which are less than or equal to 13 characters long. If this value is + not provided, vmName will be used as host name. + :paramtype host_name: str + :keyword network_interfaces: The list of network interface name objects for the selected + virtual machine. Currently, only one network interface is supported per virtual machine. + :paramtype network_interfaces: + list[~azure.mgmt.workloadssapvirtualinstance.models.NetworkInterfaceResourceNames] + :keyword os_disk_name: The full name for OS disk attached to the VM. If this value is not + provided, it will be named by ARM as per its default naming standards (prefixed with vm name). + There is only one OS disk attached per Virtual Machine. + :paramtype os_disk_name: str + :keyword data_disk_names: The full resource names for virtual machine data disks. This is a + dictionary containing list of names of data disks per volume. Currently supported volumes for + database layer are ['hana/data', 'hana/log', hana/shared', 'usr/sap', 'os', 'backup']. For + application and cs layers, only 'default' volume is supported. + :paramtype data_disk_names: dict[str, list[str]] + """ + super().__init__(**kwargs) + self.vm_name = vm_name + self.host_name = host_name + self.network_interfaces = network_interfaces + self.os_disk_name = os_disk_name + self.data_disk_names = data_disk_names + + +class WindowsConfiguration(OSConfiguration): + """Specifies Windows operating system settings on the virtual machine. + + All required parameters must be populated in order to send to server. + + :ivar os_type: The OS Type. Required. Known values are: "Linux" and "Windows". + :vartype os_type: str or ~azure.mgmt.workloadssapvirtualinstance.models.OSType + """ + + _validation = { + "os_type": {"required": True}, + } + + _attribute_map = { + "os_type": {"key": "osType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.os_type: str = "Windows" diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_patch.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_workloads_sap_virtual_instance_mgmt_client_enums.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_workloads_sap_virtual_instance_mgmt_client_enums.py new file mode 100644 index 000000000000..6d850b3973d8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/models/_workloads_sap_virtual_instance_mgmt_client_enums.py @@ -0,0 +1,224 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class ApplicationServerVirtualMachineType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the type of application server VM.""" + + ACTIVE = "Active" + STANDBY = "Standby" + UNKNOWN = "Unknown" + + +class CentralServerVirtualMachineType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the type of central server VM.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + UNKNOWN = "Unknown" + ASCS = "ASCS" + ERS_INACTIVE = "ERSInactive" + ERS = "ERS" + STANDBY = "Standby" + + +class ConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of file share config.""" + + SKIP = "Skip" + CREATE_AND_MOUNT = "CreateAndMount" + MOUNT = "Mount" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DiskSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the disk sku name.""" + + STANDARD_LRS = "Standard_LRS" + PREMIUM_LRS = "Premium_LRS" + STANDARD_SSD_LRS = "StandardSSD_LRS" + ULTRA_SSD_LRS = "UltraSSD_LRS" + PREMIUM_ZRS = "Premium_ZRS" + STANDARD_SSD_ZRS = "StandardSSD_ZRS" + PREMIUM_V2_LRS = "PremiumV2_LRS" + + +class EnqueueReplicationServerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the type of Enqueue Replication Server.""" + + ENQUEUE_REPLICATOR1 = "EnqueueReplicator1" + ENQUEUE_REPLICATOR2 = "EnqueueReplicator2" + + +class ManagedResourcesNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the network access type for managed resources.""" + + PUBLIC = "Public" + PRIVATE = "Private" + + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (only None, UserAssigned types are allowed).""" + + NONE = "None" + USER_ASSIGNED = "UserAssigned" + + +class NamingPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The pattern type to be used for resource naming.""" + + FULL_RESOURCE_NAME = "FullResourceName" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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 OSType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The OS Type.""" + + LINUX = "Linux" + WINDOWS = "Windows" + + +class SAPConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The configuration Type.""" + + DEPLOYMENT = "Deployment" + DISCOVERY = "Discovery" + DEPLOYMENT_WITH_OS_CONFIG = "DeploymentWithOSConfig" + + +class SAPDatabaseScaleMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The database scale method.""" + + SCALE_UP = "ScaleUp" + + +class SAPDatabaseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the supported SAP Database types.""" + + HANA = "HANA" + DB2 = "DB2" + + +class SAPDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of SAP deployment, single server or Three tier.""" + + SINGLE_SERVER = "SingleServer" + THREE_TIER = "ThreeTier" + + +class SAPEnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the environment type - Production/Non Production.""" + + NON_PROD = "NonProd" + PROD = "Prod" + + +class SAPHealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the health of SAP Instances.""" + + UNKNOWN = "Unknown" + HEALTHY = "Healthy" + UNHEALTHY = "Unhealthy" + DEGRADED = "Degraded" + + +class SAPHighAvailabilityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The high availability type (AvailabilitySet or AvailabilityZone).""" + + AVAILABILITY_SET = "AvailabilitySet" + AVAILABILITY_ZONE = "AvailabilityZone" + + +class SAPProductType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the SAP Product type.""" + + ECC = "ECC" + S4_HANA = "S4HANA" + OTHER = "Other" + + +class SAPSoftwareInstallationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SAP software installation Type.""" + + SERVICE_INITIATED = "ServiceInitiated" + SAP_INSTALL_WITHOUT_OS_CONFIG = "SAPInstallWithoutOSConfig" + EXTERNAL = "External" + + +class SapVirtualInstanceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the provisioning states.""" + + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + CREATING = "Creating" + FAILED = "Failed" + DELETING = "Deleting" + CANCELED = "Canceled" + + +class SAPVirtualInstanceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the Virtual Instance for SAP state.""" + + INFRASTRUCTURE_DEPLOYMENT_PENDING = "InfrastructureDeploymentPending" + INFRASTRUCTURE_DEPLOYMENT_IN_PROGRESS = "InfrastructureDeploymentInProgress" + INFRASTRUCTURE_DEPLOYMENT_FAILED = "InfrastructureDeploymentFailed" + SOFTWARE_INSTALLATION_PENDING = "SoftwareInstallationPending" + SOFTWARE_INSTALLATION_IN_PROGRESS = "SoftwareInstallationInProgress" + SOFTWARE_INSTALLATION_FAILED = "SoftwareInstallationFailed" + SOFTWARE_DETECTION_IN_PROGRESS = "SoftwareDetectionInProgress" + SOFTWARE_DETECTION_FAILED = "SoftwareDetectionFailed" + DISCOVERY_PENDING = "DiscoveryPending" + DISCOVERY_IN_PROGRESS = "DiscoveryInProgress" + DISCOVERY_FAILED = "DiscoveryFailed" + REGISTRATION_COMPLETE = "RegistrationComplete" + ACSS_INSTALLATION_BLOCKED = "ACSSInstallationBlocked" + + +class SAPVirtualInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the SAP Instance status.""" + + STARTING = "Starting" + RUNNING = "Running" + STOPPING = "Stopping" + OFFLINE = "Offline" + PARTIALLY_RUNNING = "PartiallyRunning" + UNAVAILABLE = "Unavailable" + SOFT_SHUTDOWN = "SoftShutdown" + + +class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The available API versions.""" + + V2023_10_01_PREVIEW = "2023-10-01-preview" + """The 2023-10-01-preview API version.""" diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/__init__.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/__init__.py new file mode 100644 index 000000000000..b5dcb87baf6c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._workloads_sap_virtual_instance_mgmt_client_operations import WorkloadsSapVirtualInstanceMgmtClientOperationsMixin +from ._sap_virtual_instances_operations import SAPVirtualInstancesOperations +from ._sap_central_instances_operations import SAPCentralInstancesOperations +from ._sap_database_instances_operations import SAPDatabaseInstancesOperations +from ._sap_application_server_instances_operations import SAPApplicationServerInstancesOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "WorkloadsSapVirtualInstanceMgmtClientOperationsMixin", + "SAPVirtualInstancesOperations", + "SAPCentralInstancesOperations", + "SAPDatabaseInstancesOperations", + "SAPApplicationServerInstancesOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_operations.py new file mode 100644 index 000000000000..182cc9637f0d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_operations.py @@ -0,0 +1,151 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC, _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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Workloads/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_patch.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_application_server_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_application_server_instances_operations.py new file mode 100644 index 000000000000..73d24fdb4a80 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_application_server_instances_operations.py @@ -0,0 +1,1440 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC, _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_get_request( + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "applicationInstanceName": _SERIALIZER.url( + "application_instance_name", application_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "applicationInstanceName": _SERIALIZER.url( + "application_instance_name", application_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "applicationInstanceName": _SERIALIZER.url( + "application_instance_name", application_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "applicationInstanceName": _SERIALIZER.url( + "application_instance_name", application_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_instance_request( + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}/start", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "applicationInstanceName": _SERIALIZER.url( + "application_instance_name", application_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_instance_request( + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}/stop", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "applicationInstanceName": _SERIALIZER.url( + "application_instance_name", application_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SAPApplicationServerInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_application_server_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Gets the SAP Application Server Instance corresponding to the Virtual Instance for SAP + solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPApplicationServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.SAPApplicationServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPApplicationServerInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.SAPApplicationServerInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server Instance resource. :code:`
`:code:`
`This will be used by + service only. PUT by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server Instance resource. :code:`
`:code:`
`This will be used by + service only. PUT by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.SAPApplicationServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server Instance resource. :code:`
`:code:`
`This will be used by + service only. PUT by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Is either a + SAPApplicationServerInstance type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance or + IO[bytes] + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SAPApplicationServerInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SAPApplicationServerInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.UpdateSAPApplicationInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Updates the SAP Application server instance resource. This can be used to update tags on the + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPApplicationInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Updates the SAP Application server instance resource. This can be used to update tags on the + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.UpdateSAPApplicationInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPApplicationServerInstance: + """Updates the SAP Application server instance resource. This can be used to update tags on the + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: The SAP Application Server Instance resource request body. Is either a + UpdateSAPApplicationInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPApplicationInstanceRequest + or IO[bytes] + :return: SAPApplicationServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPApplicationServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPApplicationInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPApplicationServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the SAP Application Server Instance resource. :code:`
`:code:`
`This operation + will be used by service only. Delete by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Iterable["_models.SAPApplicationServerInstance"]: + """Lists the SAP Application Server Instance resources for a given Virtual Instance for SAP + solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An iterator like instance of either SAPApplicationServerInstance or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPApplicationServerInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SAPApplicationServerInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + def _start_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance start request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance start request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance start request body. Is either a StartRequest type + or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _stop_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance stop request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance stop request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Application Server Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param application_instance_name: The name of SAP Application Server instance resource. + Required. + :type application_instance_name: str + :param body: SAP Application server instance stop request body. Is either a StopRequest type or + a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + application_instance_name=application_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_central_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_central_instances_operations.py new file mode 100644 index 000000000000..ff7d7ad385ec --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_central_instances_operations.py @@ -0,0 +1,1429 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC, _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_get_request( + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str", pattern=r"^.*"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str", pattern=r"^.*"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str", pattern=r"^.*"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str", pattern=r"^.*"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_instance_request( + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}/start", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str", pattern=r"^.*"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_instance_request( + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}/stop", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str", pattern=r"^.*"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SAPCentralInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_central_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Gets the SAP Central Services Instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPCentralServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.SAPCentralServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPCentralServerInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.SAPCentralServerInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPCentralServerInstance]: + """Creates the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. PUT operation on this resource by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPCentralServerInstance]: + """Creates the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. PUT operation on this resource by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.SAPCentralServerInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.SAPCentralServerInstance]: + """Creates the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. PUT operation on this resource by end user will return a Bad Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance request body. Is either a + SAPCentralServerInstance type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance or + IO[bytes] + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SAPCentralServerInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SAPCentralServerInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.UpdateSAPCentralInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Updates the SAP Central Services Instance resource. :code:`
`:code:`
`This can be used to + update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPCentralInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Updates the SAP Central Services Instance resource. :code:`
`:code:`
`This can be used to + update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.UpdateSAPCentralInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPCentralServerInstance: + """Updates the SAP Central Services Instance resource. :code:`
`:code:`
`This can be used to + update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: The SAP Central Services Instance resource request body. Is either a + UpdateSAPCentralInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPCentralInstanceRequest or + IO[bytes] + :return: SAPCentralServerInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPCentralServerInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPCentralInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPCentralServerInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the SAP Central Services Instance resource. :code:`
`:code:`
`This will be used + by service only. Delete operation on this resource by end user will return a Bad Request error. + You can delete the parent resource, which is the Virtual Instance for SAP solutions resource, + using the delete operation on it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Iterable["_models.SAPCentralServerInstance"]: + """Lists the SAP Central Services Instance resource for the given Virtual Instance for SAP + solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An iterator like instance of either SAPCentralServerInstance or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPCentralInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SAPCentralInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + def _start_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance start request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance start request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance start request body. Is either a StartRequest type or + a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _stop_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance stop request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance stop request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Central Services Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param central_instance_name: Central Services Instance resource name string modeled as + parameter for auto generation to work correctly. Required. + :type central_instance_name: str + :param body: SAP Central Services instance stop request body. Is either a StopRequest type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + central_instance_name=central_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_database_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_database_instances_operations.py new file mode 100644 index 000000000000..5831290bc812 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_database_instances_operations.py @@ -0,0 +1,1437 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC, _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_get_request( + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "databaseInstanceName": _SERIALIZER.url( + "database_instance_name", database_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "databaseInstanceName": _SERIALIZER.url( + "database_instance_name", database_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "databaseInstanceName": _SERIALIZER.url( + "database_instance_name", database_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "databaseInstanceName": _SERIALIZER.url( + "database_instance_name", database_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_instance_request( + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}/start", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "databaseInstanceName": _SERIALIZER.url( + "database_instance_name", database_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_instance_request( + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}/stop", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + "databaseInstanceName": _SERIALIZER.url( + "database_instance_name", database_instance_name, "str", pattern=r"^.*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SAPDatabaseInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_database_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Gets the SAP Database Instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPDatabaseInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.SAPDatabaseInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPDatabaseInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.SAPDatabaseInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPDatabaseInstance]: + """Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. PUT by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Request body of Database resource of a SAP system. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPDatabaseInstance]: + """Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. PUT by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Request body of Database resource of a SAP system. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.SAPDatabaseInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.SAPDatabaseInstance]: + """Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. PUT by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Request body of Database resource of a SAP system. Is either a SAPDatabaseInstance + type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance or IO[bytes] + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SAPDatabaseInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SAPDatabaseInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.UpdateSAPDatabaseInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Updates the Database instance resource. This can be used to update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Database resource update request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPDatabaseInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Updates the Database instance resource. This can be used to update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Database resource update request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.UpdateSAPDatabaseInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPDatabaseInstance: + """Updates the Database instance resource. This can be used to update tags on the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Database resource update request body. Is either a + UpdateSAPDatabaseInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPDatabaseInstanceRequest or + IO[bytes] + :return: SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDatabaseInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPDatabaseInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPDatabaseInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource. + :code:`
`:code:`
`This will be used by service only. Delete by end user will return a Bad + Request error. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Iterable["_models.SAPDatabaseInstance"]: + """Lists the Database resources associated with a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An iterator like instance of either SAPDatabaseInstance or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPDatabaseInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SAPDatabaseInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + def _start_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: SAP Database server instance start request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: SAP Database server instance start request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_start_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: SAP Database server instance start request body. Is either a StartRequest type or + a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _stop_instance_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_instance_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Stop request for the database instance of the SAP system. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Stop request for the database instance of the SAP system. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_stop_instance( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the database instance of the SAP system. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. + :type database_instance_name: str + :param body: Stop request for the database instance of the SAP system. Is either a StopRequest + type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_instance_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + database_instance_name=database_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_virtual_instances_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_virtual_instances_operations.py new file mode 100644 index 000000000000..c7d5697c71fe --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_sap_virtual_instances_operations.py @@ -0,0 +1,1492 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC, _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_create_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances", + ) # 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/sapVirtualInstances" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop", + ) # 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 + ), + "sapVirtualInstanceName": _SERIALIZER.url( + "sap_virtual_instance_name", sap_virtual_instance_name, "str", pattern=r"^[a-zA-Z][a-zA-Z0-9]{2}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SAPVirtualInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloadssapvirtualinstance.WorkloadsSapVirtualInstanceMgmtClient`'s + :attr:`sap_virtual_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.SAPVirtualInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPVirtualInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "SAPVirtualInstance") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.SAPVirtualInstance] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPVirtualInstance]: + """Creates a Virtual Instance for SAP solutions (VIS) resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Virtual Instance for SAP solutions resource request body. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPVirtualInstance]: + """Creates a Virtual Instance for SAP solutions (VIS) resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Virtual Instance for SAP solutions resource request body. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.SAPVirtualInstance, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.SAPVirtualInstance]: + """Creates a Virtual Instance for SAP solutions (VIS) resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Virtual Instance for SAP solutions resource request body. Is either a + SAPVirtualInstance type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance or IO[bytes] + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SAPVirtualInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SAPVirtualInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get( + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> _models.SAPVirtualInstance: + """Gets a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPVirtualInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.UpdateSAPVirtualInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPVirtualInstance: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "UpdateSAPVirtualInstanceRequest") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.UpdateSAPVirtualInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPVirtualInstance]: + """Updates a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Request body to update a Virtual Instance for SAP solutions resource. Default + value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPVirtualInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPVirtualInstance]: + """Updates a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Request body to update a Virtual Instance for SAP solutions resource. Default + value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.UpdateSAPVirtualInstanceRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.SAPVirtualInstance]: + """Updates a Virtual Instance for SAP solutions resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: Request body to update a Virtual Instance for SAP solutions resource. Is either a + UpdateSAPVirtualInstanceRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.UpdateSAPVirtualInstanceRequest or + IO[bytes] + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPVirtualInstance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SAPVirtualInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SAPVirtualInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Virtual Instance for SAP solutions resource and its child resources, that is the + associated Central Services Instance, Application Server Instances and Database Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SAPVirtualInstance"]: + """Gets all Virtual Instances for SAP solutions resources in a Resource Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPVirtualInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SAPVirtualInstance"]: + """Gets all Virtual Instances for SAP solutions resources in a Subscription. + + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.workloadssapvirtualinstance.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SAPVirtualInstanceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SAPVirtualInstanceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + def _start_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StartRequest") + else: + _json = None + + _request = build_start_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_start( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.StartRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP application, that is the Central Services instance and Application server + instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource start request body. Default value + is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP application, that is the Central Services instance and Application server + instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource start request body. Default value + is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_start( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StartRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Starts the SAP application, that is the Central Services instance and Application server + instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource start request body. Is either a + StartRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StartRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _stop_initial( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None + + _request = build_stop_request( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.StopRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Application, that is the Application server instances and Central Services + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource stop request body. Default value + is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Application, that is the Application server instances and Central Services + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource stop request body. Default value + is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[Union[_models.StopRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Stops the SAP Application, that is the Application server instances and Central Services + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. + :type sap_virtual_instance_name: str + :param body: The Virtual Instance for SAP solutions resource stop request body. Is either a + StopRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.workloadssapvirtualinstance.models.StopRequest or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloadssapvirtualinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + sap_virtual_instance_name=sap_virtual_instance_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_workloads_sap_virtual_instance_mgmt_client_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_workloads_sap_virtual_instance_mgmt_client_operations.py new file mode 100644 index 000000000000..9d2695f3eb07 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/operations/_workloads_sap_virtual_instance_mgmt_client_operations.py @@ -0,0 +1,667 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import WorkloadsSapVirtualInstanceMgmtClientMixinABC, _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_sap_sizing_recommendations_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSizingRecommendations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sap_supported_sku_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSapSupportedSku", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sap_disk_configurations_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getDiskConfigurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sap_availability_zone_details_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkloadsSapVirtualInstanceMgmtClientOperationsMixin( # pylint: disable=name-too-long + WorkloadsSapVirtualInstanceMgmtClientMixinABC +): + @overload + def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[_models.SAPSizingRecommendationRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Default value is + None. + :type sap_sizing_recommendation: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Default value is + None. + :type sap_sizing_recommendation: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[Union[_models.SAPSizingRecommendationRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Is either a + SAPSizingRecommendationRequest type or a IO[bytes] type. Default value is None. + :type sap_sizing_recommendation: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationRequest or IO[bytes] + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPSizingRecommendationResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_sizing_recommendation, (IOBase, bytes)): + _content = sap_sizing_recommendation + else: + if sap_sizing_recommendation is not None: + _json = self._serialize.body(sap_sizing_recommendation, "SAPSizingRecommendationRequest") + else: + _json = None + + _request = build_sap_sizing_recommendations_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPSizingRecommendationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[_models.SAPSupportedSkusRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Default value is None. + :type sap_supported_sku: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedSkusRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Default value is None. + :type sap_supported_sku: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[Union[_models.SAPSupportedSkusRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Is either a SAPSupportedSkusRequest + type or a IO[bytes] type. Default value is None. + :type sap_supported_sku: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedSkusRequest + or IO[bytes] + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPSupportedResourceSkusResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_supported_sku, (IOBase, bytes)): + _content = sap_supported_sku + else: + if sap_supported_sku is not None: + _json = self._serialize.body(sap_supported_sku, "SAPSupportedSkusRequest") + else: + _json = None + + _request = build_sap_supported_sku_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPSupportedResourceSkusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[_models.SAPDiskConfigurationsRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Default value is None. + :type sap_disk_configurations: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Default value is None. + :type sap_disk_configurations: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[Union[_models.SAPDiskConfigurationsRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Is either a + SAPDiskConfigurationsRequest type or a IO[bytes] type. Default value is None. + :type sap_disk_configurations: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsRequest or IO[bytes] + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPDiskConfigurationsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_disk_configurations, (IOBase, bytes)): + _content = sap_disk_configurations + else: + if sap_disk_configurations is not None: + _json = self._serialize.body(sap_disk_configurations, "SAPDiskConfigurationsRequest") + else: + _json = None + + _request = build_sap_disk_configurations_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPDiskConfigurationsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[_models.SAPAvailabilityZoneDetailsRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_availability_zone_details: SAP Availability Zone Details Request body. Default value + is None. + :type sap_availability_zone_details: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_availability_zone_details: SAP Availability Zone Details Request body. Default value + is None. + :type sap_availability_zone_details: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[Union[_models.SAPAvailabilityZoneDetailsRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. + + :param location: The name of Azure region. Required. + :type location: str + :param sap_availability_zone_details: SAP Availability Zone Details Request body. Is either a + SAPAvailabilityZoneDetailsRequest type or a IO[bytes] type. Default value is None. + :type sap_availability_zone_details: + ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsRequest or IO[bytes] + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloadssapvirtualinstance.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SAPAvailabilityZoneDetailsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_availability_zone_details, (IOBase, bytes)): + _content = sap_availability_zone_details + else: + if sap_availability_zone_details is not None: + _json = self._serialize.body(sap_availability_zone_details, "SAPAvailabilityZoneDetailsRequest") + else: + _json = None + + _request = build_sap_availability_zone_details_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("SAPAvailabilityZoneDetailsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/py.typed b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/azure/mgmt/workloadssapvirtualinstance/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/dev_requirements.txt b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/dev_requirements.txt new file mode 100644 index 000000000000..13ab3cd586ac --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +-e ../../../tools/azure-devtools +../../identity/azure-identity diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/operations_list.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/operations_list.py new file mode 100644 index 000000000000..3aa046cfea8c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/operations_list.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python operations_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/operations/preview/2023-10-01-preview/examples/Operations_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_create.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_create.py new file mode 100644 index 000000000000..25e01c1ed1f8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_create.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_create_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_create_ha_av_set.py new file mode 100644 index 000000000000..e3bf52b6227a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_create_ha_av_set.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_create_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_Create_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_delete.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_delete.py new file mode 100644 index 000000000000..021aa0c99327 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + client.sap_application_server_instances.begin_delete( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_get.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_get.py new file mode 100644 index 000000000000..22401322f9e2 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.get( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_list.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_list.py new file mode 100644 index 000000000000..3823cfd78bc8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.list( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_start_instance.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_start_instance.py new file mode 100644 index 000000000000..5c9703b3869f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_start_instance.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_start_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_application_server_instances.begin_start_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_StartInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_start_instance_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_start_instance_with_infra_operations.py new file mode 100644 index 000000000000..c12e3173384e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_start_instance_with_infra_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_start_instance_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_application_server_instances.begin_start_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_StartInstance_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_stop_instance.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_stop_instance.py new file mode 100644 index 000000000000..73c6a9721a3e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_stop_instance.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_stop_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_application_server_instances.begin_stop_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_StopInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_stop_instance_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_stop_instance_with_infra_operations.py new file mode 100644 index 000000000000..0e1ae376b58b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_stop_instance_with_infra_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_stop_instance_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_application_server_instances.begin_stop_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_StopInstance_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_update.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_update.py new file mode 100644 index 000000000000..91baa9da3203 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapapplicationinstances/sap_application_server_instances_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_application_server_instances_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.update( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + application_instance_name="app01", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapapplicationinstances/SAPApplicationServerInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_create.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_create.py new file mode 100644 index 000000000000..38f1d85c7b33 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_create.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_create_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_create_ha_av_set.py new file mode 100644 index 000000000000..594f86cf9590 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_create_ha_av_set.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_create_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_Create_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_delete.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_delete.py new file mode 100644 index 000000000000..eb2eaf02057c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + client.sap_central_instances.begin_delete( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_get.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_get.py new file mode 100644 index 000000000000..9511274fcfd0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.get( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_list.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_list.py new file mode 100644 index 000000000000..dc73d3aef204 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.list( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_start_instance.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_start_instance.py new file mode 100644 index 000000000000..4a3e830d8488 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_start_instance.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_start_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_central_instances.begin_start_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_StartInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_start_instance_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_start_instance_with_infra_operations.py new file mode 100644 index 000000000000..abecc9475e01 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_start_instance_with_infra_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_start_instance_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_central_instances.begin_start_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_StartInstance_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_stop_instance.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_stop_instance.py new file mode 100644 index 000000000000..59bc0950e4e5 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_stop_instance.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_stop_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_central_instances.begin_stop_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_StopInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_stop_instance_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_stop_instance_with_infra_operations.py new file mode 100644 index 000000000000..cf5567bc6825 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_stop_instance_with_infra_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_stop_instance_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_central_instances.begin_stop_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_StopInstance_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_update.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_update.py new file mode 100644 index 000000000000..0ef5e1d7b25a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapcentralinstances/sap_central_instances_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_central_instances_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.update( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + central_instance_name="centralServer", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapcentralinstances/SAPCentralInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_create.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_create.py new file mode 100644 index 000000000000..42a6b622ddaa --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_create.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="databaseServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_create_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_create_ha_av_set.py new file mode 100644 index 000000000000..5a26772822ea --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_create_ha_av_set.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_create_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="databaseServer", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_Create_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_delete.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_delete.py new file mode 100644 index 000000000000..42e520c218d6 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + client.sap_database_instances.begin_delete( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="databaseServer", + ).result() + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_get.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_get.py new file mode 100644 index 000000000000..cefe5ecc8607 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.get( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="databaseServer", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_list.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_list.py new file mode 100644 index 000000000000..f2e75a74c2da --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.list( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_start_instance.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_start_instance.py new file mode 100644 index 000000000000..d1895561bee2 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_start_instance.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_start_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_database_instances.begin_start_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="db0", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_StartInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_start_instance_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_start_instance_with_infra_operations.py new file mode 100644 index 000000000000..c2e7b8c9b4bc --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_start_instance_with_infra_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_start_instance_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_database_instances.begin_start_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="db0", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_StartInstance_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_stop_instance.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_stop_instance.py new file mode 100644 index 000000000000..e649f37dae65 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_stop_instance.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_stop_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_database_instances.begin_stop_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="db0", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_StopInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_stop_instance_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_stop_instance_with_infra_operations.py new file mode 100644 index 000000000000..969d53148fda --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_stop_instance_with_infra_operations.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_stop_instance_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_database_instances.begin_stop_instance( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="db0", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_StopInstance_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_update.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_update.py new file mode 100644 index 000000000000..d58d38a18ccb --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapdatabaseinstances/sap_database_instances_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_database_instances_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.update( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + database_instance_name="databaseServer", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapdatabaseinstances/SAPDatabaseInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_availability_zone_details_eastus.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_availability_zone_details_eastus.py new file mode 100644 index 000000000000..22ee7643035a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_availability_zone_details_eastus.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_availability_zone_details_eastus.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_availability_zone_details( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPAvailabilityZoneDetails_eastus.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_availability_zone_details_northeurope.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_availability_zone_details_northeurope.py new file mode 100644 index 000000000000..528c1700e402 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_availability_zone_details_northeurope.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_availability_zone_details_northeurope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_availability_zone_details( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPAvailabilityZoneDetails_northeurope.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_disk_configurations_non_prod.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_disk_configurations_non_prod.py new file mode 100644 index 000000000000..e749844e9394 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_disk_configurations_non_prod.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_disk_configurations_non_prod.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_disk_configurations( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPDiskConfigurations_NonProd.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_disk_configurations_prod.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_disk_configurations_prod.py new file mode 100644 index 000000000000..fa89227a7861 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_disk_configurations_prod.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_disk_configurations_prod.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_disk_configurations( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPDiskConfigurations_Prod.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_distributed.py new file mode 100644 index 000000000000..9c9007eb1706 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_distributed.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_sizing_recommendations_s4_hana_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_sizing_recommendations( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_ha_av_set.py new file mode 100644 index 000000000000..235fc71a1432 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_ha_av_set.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_sizing_recommendations_s4_hana_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_sizing_recommendations( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_ha_av_zone.py new file mode 100644 index 000000000000..9e74e6f57a0b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_ha_av_zone.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_sizing_recommendations_s4_hana_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_sizing_recommendations( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_single_server.py new file mode 100644 index 000000000000..79c8973da481 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_sizing_recommendations_s4_hana_single_server.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_sizing_recommendations_s4_hana_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_sizing_recommendations( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed.py new file mode 100644 index 000000000000..7fd5f316b155 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_supported_skus_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_supported_sku( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed_ha_av_set.py new file mode 100644 index 000000000000..35c905785ccb --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed_ha_av_set.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_supported_skus_distributed_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_supported_sku( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_DistributedHA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed_ha_av_zone.py new file mode 100644 index 000000000000..7c78217c928c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_distributed_ha_av_zone.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_supported_skus_distributed_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_supported_sku( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_DistributedHA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_single_server.py new file mode 100644 index 000000000000..896ded39ba53 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_supported_skus_single_server.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_supported_skus_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_supported_sku( + location="centralus", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_distributed.py new file mode 100644 index 000000000000..c73075f2a5ef --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_distributed.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_custom_full_resource_names_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_CustomFullResourceNames_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_ha_av_set.py new file mode 100644 index 000000000000..1875f35c7b8d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_ha_av_set.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_custom_full_resource_names_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_CustomFullResourceNames_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_ha_av_zone.py new file mode 100644 index 000000000000..3d9c7c428603 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_ha_av_zone.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_custom_full_resource_names_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_CustomFullResourceNames_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_single_server.py new file mode 100644 index 000000000000..b4a4b629e083 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_full_resource_names_single_server.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_custom_full_resource_names_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_CustomFullResourceNames_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_image.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_image.py new file mode 100644 index 000000000000..5a2483d5d5d1 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_custom_image.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_custom_image.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Custom_Image.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover.py new file mode 100644 index 000000000000..d5d168222f19 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_discover.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Discover.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover_custom_mrg_storage_account_name.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover_custom_mrg_storage_account_name.py new file mode 100644 index 000000000000..1b0dc64ad719 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover_custom_mrg_storage_account_name.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_discover_custom_mrg_storage_account_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Discover_CustomMrgStorageAccountName.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover_trusted_access_enable.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover_trusted_access_enable.py new file mode 100644 index 000000000000..3f91ed82cb07 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_discover_trusted_access_enable.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_discover_trusted_access_enable.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Discover_TrustedAccessEnable.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_distributed.py new file mode 100644 index 000000000000..411fff50529a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_distributed.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_disk_details_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_DiskDetails_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_ha_av_set.py new file mode 100644 index 000000000000..51cb6dab7a49 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_ha_av_set.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_disk_details_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_DiskDetails_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_ha_av_zone.py new file mode 100644 index 000000000000..f4e23d4a7300 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_ha_av_zone.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_disk_details_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_DiskDetails_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_single_server.py new file mode 100644 index 000000000000..7f5864a17525 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_disk_details_single_server.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_disk_details_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_DiskDetails_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed.py new file mode 100644 index 000000000000..e3c20b03fb6a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_create_transport.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_create_transport.py new file mode 100644 index 000000000000..78ac48b02ff3 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_create_transport.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_distributed_create_transport.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Distributed_CreateTransport.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_mount_transport.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_mount_transport.py new file mode 100644 index 000000000000..cb0d70d1ca2d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_mount_transport.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_distributed_mount_transport.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Distributed_MountTransport.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_skip_transport.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_skip_transport.py new file mode 100644 index 000000000000..83dbdca2c1c6 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_distributed_skip_transport.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_distributed_skip_transport.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Distributed_SkipTransport.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_ha_av_set.py new file mode 100644 index 000000000000..70bb3e4ccd33 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_ha_av_set.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_ha_av_zone.py new file mode 100644 index 000000000000..513e3664e8ee --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_ha_av_zone.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_single_server.py new file mode 100644 index 000000000000..9b51d18e3e6d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_single_server.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_distributed.py new file mode 100644 index 000000000000..32961c8358a9 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_distributed.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_with_os_config_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_ha_av_set.py new file mode 100644 index 000000000000..f0f25affc481 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_ha_av_set.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_with_os_config_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_ha_av_zone.py new file mode 100644 index 000000000000..94ce133f047b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_ha_av_zone.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_with_os_config_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_single_server.py new file mode 100644 index 000000000000..61e4ce1e2974 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_single_server.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_with_os_config_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_with_trusted_access.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_with_trusted_access.py new file mode 100644 index 000000000000..e170b0921442 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_create_with_os_config_with_trusted_access.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_create_with_os_config_with_trusted_access.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_WithTrustedAccess.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_delete.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_delete.py new file mode 100644 index 000000000000..a21bcfaff704 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + client.sap_virtual_instances.begin_delete( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_distributed.py new file mode 100644 index 000000000000..a8f050c35b54 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_distributed.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_detect_installation_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_ha_av_set.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_ha_av_set.py new file mode 100644 index 000000000000..7aff12ccc113 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_ha_av_set.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_detect_installation_ha_av_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_ha_av_zone.py new file mode 100644 index 000000000000..98d4ed222c81 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_ha_av_zone.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_detect_installation_ha_av_zone.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_single_server.py new file mode 100644 index 000000000000..86e13d704afe --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_detect_installation_single_server.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_detect_installation_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_get.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_get.py new file mode 100644 index 000000000000..3633cdb308b2 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.get( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_get_acssinstallation_blocked.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_get_acssinstallation_blocked.py new file mode 100644 index 000000000000..a4453a798a25 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_get_acssinstallation_blocked.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_get_acssinstallation_blocked.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.get( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Get_ACSSInstallationBlocked.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_install_distributed.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_install_distributed.py new file mode 100644 index 000000000000..dd3b760c9946 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_install_distributed.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_install_distributed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Install_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_install_single_server.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_install_single_server.py new file mode 100644 index 000000000000..6c9276ae02d8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_install_single_server.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_install_single_server.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_create( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Install_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_list_by_resource_group.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_list_by_resource_group.py new file mode 100644 index 000000000000..4ba9031185de --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_list_by_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_virtual_instances.list_by_resource_group( + resource_group_name="test-rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_list_by_subscription.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_list_by_subscription.py new file mode 100644 index 000000000000..c7f9e4147ad4 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_list_by_subscription.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_virtual_instances.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_start.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_start.py new file mode 100644 index 000000000000..c26c89e54c63 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_start.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_start.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_start( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Start.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_start_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_start_with_infra_operations.py new file mode 100644 index 000000000000..bf75631f3c05 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_start_with_infra_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_start_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_start( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Start_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_stop.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_stop.py new file mode 100644 index 000000000000..4162335c66d3 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_stop.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_stop.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_stop( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Stop.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_stop_with_infra_operations.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_stop_with_infra_operations.py new file mode 100644 index 000000000000..62a9a33d1182 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_stop_with_infra_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_stop_with_infra_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_stop( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Stop_WithInfraOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_trusted_access_enable_update.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_trusted_access_enable_update.py new file mode 100644 index 000000000000..beb546f7d200 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_trusted_access_enable_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_trusted_access_enable_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_update( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_TrustedAccessEnable_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_update.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_update.py new file mode 100644 index 000000000000..26d4c7a64178 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/generated_samples/sapvirtualinstances/sap_virtual_instances_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.workloadssapvirtualinstance import WorkloadsSapVirtualInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloadssapvirtualinstance +# USAGE + python sap_virtual_instances_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WorkloadsSapVirtualInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.begin_update( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/SAPVirtualInstance/preview/2023-10-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/sdk_packaging.toml b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/sdk_packaging.toml new file mode 100644 index 000000000000..21939d8ce115 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/sdk_packaging.toml @@ -0,0 +1,12 @@ +[packaging] +package_name = "azure-mgmt-workloadssapvirtualinstance" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Workloadssapvirtualinstance Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" +title = "WorkloadsSapVirtualInstanceMgmtClient" diff --git a/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/setup.py b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/setup.py new file mode 100644 index 000000000000..89381e57a658 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloadssapvirtualinstance/setup.py @@ -0,0 +1,82 @@ +#!/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-workloadssapvirtualinstance" +PACKAGE_PPRINT_NAME = "Workloadssapvirtualinstance 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.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), + include_package_data=True, + package_data={ + "pytyped": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", + ], + python_requires=">=3.8", +) diff --git a/sdk/workloads/ci.yml b/sdk/workloads/ci.yml index 94b5fc091e01..f4637be3df5e 100644 --- a/sdk/workloads/ci.yml +++ b/sdk/workloads/ci.yml @@ -31,3 +31,5 @@ extends: Artifacts: - name: azure-mgmt-workloads safeName: azuremgmtworkloads + - name: azure-mgmt-workloadssapvirtualinstance + safeName: azuremgmtworkloadssapvirtualinstance diff --git a/tools/azure-sdk-tools/packaging_tools/generate_utils.py b/tools/azure-sdk-tools/packaging_tools/generate_utils.py index a40540573e2b..e42cb7ca5517 100644 --- a/tools/azure-sdk-tools/packaging_tools/generate_utils.py +++ b/tools/azure-sdk-tools/packaging_tools/generate_utils.py @@ -7,7 +7,7 @@ from ci_tools.git_tools import get_add_diff_file_list from pathlib import Path -from subprocess import check_output, CalledProcessError, check_call +from subprocess import check_output, CalledProcessError, check_call, getoutput from typing import Dict, Any from glob import glob import yaml @@ -75,11 +75,9 @@ def call_build_config(package_name: str, folder_name: str): # shell=True, # ) -def init_new_service(package_name, folder_name, is_typespec = False): - if not is_typespec: - setup = Path(folder_name, package_name, "setup.py") - if not setup.exists(): - call_build_config(package_name, folder_name) +def init_new_service(package_name, folder_name): + if "azure-mgmt-" in package_name: + call_build_config(package_name, folder_name) else: output_path = Path(folder_name) / package_name if not (output_path / CONF_NAME).exists(): @@ -99,16 +97,11 @@ def update_servicemetadata(sdk_folder, data, config, folder_name, package_name, if not package_folder.exists(): _LOGGER.info(f"Fail to save metadata since package folder doesn't exist: {package_folder}") return - if not (package_folder / "_meta.json").exists(): - metadata = {} - else: - with open(str(package_folder / "_meta.json"), "r") as file_in: - metadata = json.load(file_in) - metadata.update({ + metadata = { "commit": data["headSha"], "repository_url": data["repoHttpsUrl"], - }) + } if "meta" in config: readme_file = str(Path(spec_folder, input_readme)) global_conf = config["meta"] @@ -383,7 +376,7 @@ def generate_ci(template_path: Path, folder_path: Path, package_name: str) -> No def gen_typespec(typespec_relative_path: str, spec_folder: str, head_sha: str, rest_repo_url: str) -> Dict[str, Any]: typespec_python = "@azure-tools/typespec-python" - + autorest_python = "@autorest/python" # call scirpt to generate sdk try: check_output(f'pwsh {Path("eng/common/scripts/TypeSpec-Project-Process.ps1")} {(Path(spec_folder) / typespec_relative_path).resolve()} {head_sha} {rest_repo_url}', shell=True) @@ -392,8 +385,12 @@ def gen_typespec(typespec_relative_path: str, spec_folder: str, head_sha: str, r raise e # get version of codegen used in generation + autorest_python_version = getoutput(f"npm show {autorest_python} version") with open(Path("eng/emitter-package.json"), "r") as file_in: data = json.load(file_in) - npm_package_verstion = {typespec_python: data["dependencies"][typespec_python]} + npm_package_verstion = { + typespec_python: data["dependencies"][typespec_python], + autorest_python: autorest_python_version, + } return npm_package_verstion diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py index 02d6b5cb5ee5..f8acf613b7da 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py @@ -268,7 +268,6 @@ def main(generate_input, generate_output): for input_readme in readme_files: _LOGGER.info(f"[CODEGEN]({input_readme})codegen begin") - is_typespec = False if "resource-manager" in input_readme: relative_path_readme = str(Path(spec_folder, input_readme)) update_metadata_for_multiapi_package(spec_folder, input_readme) @@ -286,7 +285,6 @@ def main(generate_input, generate_output): config = gen_dpg(input_readme, data.get("autorestConfig", ""), dpg_relative_folder(spec_folder)) else: config = gen_typespec(input_readme, spec_folder, data["headSha"], data["repoHttpsUrl"]) - is_typespec = True package_names = get_package_names(sdk_folder) _LOGGER.info(f"[CODEGEN]({input_readme})codegen end. [(packages:{str(package_names)})]") @@ -309,7 +307,7 @@ def main(generate_input, generate_output): result[package_name][spec_word].append(input_readme) # Generate some necessary file for new service - init_new_service(package_name, folder_name, is_typespec) + init_new_service(package_name, folder_name) format_samples(sdk_code_path) # Update metadata