diff --git a/sdk/workloads/azure-mgmt-workloads/_meta.json b/sdk/workloads/azure-mgmt-workloads/_meta.json index e2b35cf01fcb..a3653dffe01c 100644 --- a/sdk/workloads/azure-mgmt-workloads/_meta.json +++ b/sdk/workloads/azure-mgmt-workloads/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "6f5e3fcc03c251f713a7c43e6506cca8592ac971", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "2d6cb29af754f48a08f94cb6113bb1f01a4e0eb9", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/workloads/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/workloads/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/workloads/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py index 8f2b5059c9df..6d1de2021d43 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['WorkloadsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "WorkloadsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py index bef7edc93f1c..84b908711420 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class WorkloadsClientConfiguration(Configuration): # pylint: disable=too-many-i 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. + :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. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(WorkloadsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-12-01-preview") # type: Literal["2021-12-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-workloads/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-workloads/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_serialization.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# 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 + +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 + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +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, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> 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: + # 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_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], 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 + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_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 +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 # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? 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=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(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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + 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 = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, 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 = [ + 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_with_traceback(SerializationError, "Unable to build a model: " + str(err), 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) + 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. + :rtype: str + :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] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # 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_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_with_traceback(SerializationError, msg.format(data, data_type), 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): + # 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'. + :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: + serialized.append(None) + + 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: + 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 unicode_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) + return result + except ValueError: + for enum_value in enum_obj: + 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_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, 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: + 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 = 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 + # https://github.com/Azure/msrest-for-python/issues/197 + 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 + # https://github.com/Azure/msrest-for-python/issues/197 + 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=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(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, basestring): + 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 + 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 + raise_with_traceback(DeserializationError, msg, 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 deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + 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 deseralize. + :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, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + 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) + 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_with_traceback(DeserializationError, msg, 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, basestring): + 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, basestring): + 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): + 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. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + 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)) + + @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) + attr = attr + padding + 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(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, 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) + + @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_with_traceback(DeserializationError, msg, 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): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @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): + 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) + 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_with_traceback(DeserializationError, msg, 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() + 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_with_traceback(DeserializationError, msg, 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) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py index 138f663c53a4..2eb4e11d58b3 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_vendor.py @@ -5,8 +5,20 @@ # 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 WorkloadsClientConfiguration + +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) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class WorkloadsClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: WorkloadsClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py index 253419521122..e8a862adfb8e 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/_workloads_client.py @@ -9,20 +9,34 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models from ._configuration import WorkloadsClientConfiguration -from .operations import MonitorsOperations, Operations, PhpWorkloadsOperations, ProviderInstancesOperations, SAPApplicationServerInstancesOperations, SAPCentralInstancesOperations, SAPDatabaseInstancesOperations, SAPVirtualInstancesOperations, SkusOperations, WordpressInstancesOperations, WorkloadsClientOperationsMixin +from ._serialization import Deserializer, Serializer +from .operations import ( + MonitorsOperations, + Operations, + PhpWorkloadsOperations, + ProviderInstancesOperations, + SAPApplicationServerInstancesOperations, + SAPCentralInstancesOperations, + SAPDatabaseInstancesOperations, + SAPVirtualInstancesOperations, + SkusOperations, + WordpressInstancesOperations, + WorkloadsClientOperationsMixin, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class WorkloadsClient(WorkloadsClientOperationsMixin): # pylint: disable=too-many-instance-attributes + +class WorkloadsClient( + WorkloadsClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Workloads client provides access to various workload operations. :ivar php_workloads: PhpWorkloadsOperations operations @@ -46,9 +60,9 @@ class WorkloadsClient(WorkloadsClientOperationsMixin): # pylint: disable=too- :vartype provider_instances: azure.mgmt.workloads.operations.ProviderInstancesOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.workloads.operations.SkusOperations - :param credential: Credential needed for the client to connect to Azure. + :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. + :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 @@ -74,22 +88,29 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.php_workloads = PhpWorkloadsOperations(self._client, self._config, self._serialize, self._deserialize) - self.wordpress_instances = WordpressInstancesOperations(self._client, self._config, self._serialize, self._deserialize) - 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.wordpress_instances = WordpressInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + 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) self.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_instances = ProviderInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_instances = ProviderInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -98,7 +119,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py index 0d869187c5dd..5159cde1437e 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._workloads_client import WorkloadsClient -__all__ = ['WorkloadsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "WorkloadsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py index 61293a606e85..8a2a47a210de 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class WorkloadsClientConfiguration(Configuration): # pylint: disable=too-many-i 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. + :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. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(WorkloadsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-12-01-preview") # type: Literal["2021-12-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-workloads/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-workloads/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_vendor.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_vendor.py new file mode 100644 index 000000000000..06d58dc0155e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/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 WorkloadsClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class WorkloadsClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: WorkloadsClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py index e46fe69426e1..76cd386623d6 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/_workloads_client.py @@ -9,20 +9,34 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import WorkloadsClientConfiguration -from .operations import MonitorsOperations, Operations, PhpWorkloadsOperations, ProviderInstancesOperations, SAPApplicationServerInstancesOperations, SAPCentralInstancesOperations, SAPDatabaseInstancesOperations, SAPVirtualInstancesOperations, SkusOperations, WordpressInstancesOperations, WorkloadsClientOperationsMixin +from .operations import ( + MonitorsOperations, + Operations, + PhpWorkloadsOperations, + ProviderInstancesOperations, + SAPApplicationServerInstancesOperations, + SAPCentralInstancesOperations, + SAPDatabaseInstancesOperations, + SAPVirtualInstancesOperations, + SkusOperations, + WordpressInstancesOperations, + WorkloadsClientOperationsMixin, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class WorkloadsClient(WorkloadsClientOperationsMixin): # pylint: disable=too-many-instance-attributes + +class WorkloadsClient( + WorkloadsClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Workloads client provides access to various workload operations. :ivar php_workloads: PhpWorkloadsOperations operations @@ -49,9 +63,9 @@ class WorkloadsClient(WorkloadsClientOperationsMixin): # pylint: disable=too- :vartype provider_instances: azure.mgmt.workloads.aio.operations.ProviderInstancesOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.workloads.aio.operations.SkusOperations - :param credential: Credential needed for the client to connect to Azure. + :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. + :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 @@ -77,22 +91,29 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.php_workloads = PhpWorkloadsOperations(self._client, self._config, self._serialize, self._deserialize) - self.wordpress_instances = WordpressInstancesOperations(self._client, self._config, self._serialize, self._deserialize) - 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.wordpress_instances = WordpressInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + 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) self.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_instances = ProviderInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_instances = ProviderInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -101,7 +122,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py index 776a9a684ec2..517f5ecc331a 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._provider_instances_operations import ProviderInstancesOperations from ._skus_operations import SkusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PhpWorkloadsOperations', - 'WordpressInstancesOperations', - 'WorkloadsClientOperationsMixin', - 'SAPVirtualInstancesOperations', - 'SAPCentralInstancesOperations', - 'SAPDatabaseInstancesOperations', - 'SAPApplicationServerInstancesOperations', - 'Operations', - 'MonitorsOperations', - 'ProviderInstancesOperations', - 'SkusOperations', + "PhpWorkloadsOperations", + "WordpressInstancesOperations", + "WorkloadsClientOperationsMixin", + "SAPVirtualInstancesOperations", + "SAPCentralInstancesOperations", + "SAPDatabaseInstancesOperations", + "SAPApplicationServerInstancesOperations", + "Operations", + "MonitorsOperations", + "ProviderInstancesOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py index 7db6cb23ed09..2166ad8b6eed 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_monitors_operations.py @@ -6,89 +6,124 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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._monitors_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._monitors_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitorsOperations: - """MonitorsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MonitorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`monitors` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.MonitorListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Monitor"]: """Gets a list of SAP monitors in the specified subscription. Gets a list of SAP monitors in the specified subscription. The operations returns various properties of each SAP monitor. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.MonitorListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Monitor or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -102,10 +137,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,58 +149,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.MonitorListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Monitor"]: """Gets a list of SAP monitors. Gets a list of SAP monitors in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.MonitorListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Monitor or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -181,10 +225,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -195,57 +237,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> "_models.Monitor": + async def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _models.Monitor: """Gets properties of a SAP monitor. Gets properties of a SAP monitor for the specified subscription, resource group, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Monitor, or the result of cls(response) + :return: Monitor or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.Monitor - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,89 +297,106 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore async def _create_initial( - self, - resource_group_name: str, - monitor_name: str, - monitor_parameter: "_models.Monitor", - **kwargs: Any - ) -> "_models.Monitor": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + self, resource_group_name: str, monitor_name: str, monitor_parameter: Union[_models.Monitor, IO], **kwargs: Any + ) -> _models.Monitor: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitor_parameter, 'Monitor') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitor_parameter, (IO, bytes)): + _content = monitor_parameter + else: + _json = self._serialize.body(monitor_parameter, "Monitor") + + request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, monitor_name: str, - monitor_parameter: "_models.Monitor", + monitor_parameter: _models.Monitor, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Monitor"]: + ) -> AsyncLROPoller[_models.Monitor]: """Creates a SAP monitor. Creates a SAP monitor for the specified subscription, resource group, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param monitor_parameter: Request body representing a SAP monitor. + :param monitor_parameter: Request body representing a SAP monitor. Required. :type monitor_parameter: ~azure.mgmt.workloads.models.Monitor + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -347,113 +408,195 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Monitor or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.Monitor] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + monitor_parameter: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Monitor]: + """Creates a SAP monitor. + + Creates a SAP monitor for the specified subscription, resource group, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param monitor_parameter: Request body representing a SAP monitor. Required. + :type monitor_parameter: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Monitor or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, monitor_name: str, monitor_parameter: Union[_models.Monitor, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Monitor]: + """Creates a SAP monitor. + + Creates a SAP monitor for the specified subscription, resource group, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param monitor_parameter: Request body representing a SAP monitor. Is either a model type or a + IO type. Required. + :type monitor_parameter: ~azure.mgmt.workloads.models.Monitor or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Monitor or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, monitor_parameter=monitor_parameter, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResult"]: + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: """Deletes a SAP monitor. Deletes a SAP monitor with the specified subscription, resource group, and SAP monitor name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -466,100 +609,184 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, monitor_name: str, - body: "_models.UpdateMonitorRequest", + body: _models.UpdateMonitorRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Monitor": + ) -> _models.Monitor: """Patches the Tags field of a SAP monitor. Patches the Tags field of a SAP monitor for the specified subscription, resource group, and SAP monitor name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param body: The Update SAP workload monitor request body. + :param body: The Update SAP workload monitor request body. Required. :type body: ~azure.mgmt.workloads.models.UpdateMonitorRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + monitor_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Monitor: + """Patches the Tags field of a SAP monitor. + + Patches the Tags field of a SAP monitor for the specified subscription, resource group, and SAP + monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param body: The Update SAP workload monitor request body. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Monitor, or the result of cls(response) + :return: Monitor or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.Monitor - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, monitor_name: str, body: Union[_models.UpdateMonitorRequest, IO], **kwargs: Any + ) -> _models.Monitor: + """Patches the Tags field of a SAP monitor. + + Patches the Tags field of a SAP monitor for the specified subscription, resource group, and SAP + monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param body: The Update SAP workload monitor request body. Is either a model type or a IO type. + Required. + :type body: ~azure.mgmt.workloads.models.UpdateMonitorRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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 = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] - _json = self._serialize.body(body, 'UpdateMonitorRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "UpdateMonitorRequest") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -567,12 +794,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py index 762c5bd0ae57..81af31eafd5f 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_operations.py @@ -6,82 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 -T = TypeVar('T') +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all the available API operations under this PR. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -109,8 +135,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Workloads/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Workloads/operations"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/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-workloads/azure/mgmt/workloads/aio/operations/_php_workloads_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_php_workloads_operations.py index 9f6e88ce32a3..b056b0619188 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_php_workloads_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_php_workloads_operations.py @@ -6,88 +6,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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._php_workloads_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._php_workloads_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PhpWorkloadsOperations: - """PhpWorkloadsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PhpWorkloadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`php_workloads` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PhpWorkloadResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.PhpWorkloadResource"]: """Lists PHP workload resources for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhpWorkloadResourceList or the result of - cls(response) + :return: An iterator like instance of either PhpWorkloadResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,10 +135,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,58 +147,70 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PhpWorkloadResourceList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PhpWorkloadResource"]: """Lists PHP workload 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhpWorkloadResourceList or the result of - cls(response) + :return: An iterator like instance of either PhpWorkloadResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -180,10 +224,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -194,54 +236,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any - ) -> "_models.PhpWorkloadResource": + async def get(self, resource_group_name: str, php_workload_name: str, **kwargs: Any) -> _models.PhpWorkloadResource: """Gets the PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhpWorkloadResource, or the result of cls(response) + :return: PhpWorkloadResource or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,87 +293,179 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, php_workload_name: str, - php_workload_resource: "_models.PhpWorkloadResource", + php_workload_resource: Union[_models.PhpWorkloadResource, IO], **kwargs: Any - ) -> "_models.PhpWorkloadResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] + ) -> _models.PhpWorkloadResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(php_workload_resource, 'PhpWorkloadResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(php_workload_resource, (IO, bytes)): + _content = php_workload_resource + else: + _json = self._serialize.body(php_workload_resource, "PhpWorkloadResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + php_workload_resource: _models.PhpWorkloadResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhpWorkloadResource]: + """Create or updated PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param php_workload_resource: Resource create or update request payload. Required. + :type php_workload_resource: ~azure.mgmt.workloads.models.PhpWorkloadResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PhpWorkloadResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + php_workload_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhpWorkloadResource]: + """Create or updated PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param php_workload_resource: Resource create or update request payload. Required. + :type php_workload_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PhpWorkloadResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, php_workload_name: str, - php_workload_resource: "_models.PhpWorkloadResource", + php_workload_resource: Union[_models.PhpWorkloadResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PhpWorkloadResource"]: + ) -> AsyncLROPoller[_models.PhpWorkloadResource]: """Create or updated PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str - :param php_workload_resource: Resource create or update request payload. - :type php_workload_resource: ~azure.mgmt.workloads.models.PhpWorkloadResource + :param php_workload_resource: Resource create or update request payload. Is either a model type + or a IO type. Required. + :type php_workload_resource: ~azure.mgmt.workloads.models.PhpWorkloadResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -341,100 +477,185 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PhpWorkloadResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.PhpWorkloadResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, php_workload_name=php_workload_name, php_workload_resource=php_workload_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, php_workload_name: str, - resource_patch_request_body: "_models.PatchResourceRequestBody", + resource_patch_request_body: _models.PatchResourceRequestBody, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PhpWorkloadResource": + ) -> _models.PhpWorkloadResource: """Update PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str - :param resource_patch_request_body: Workload resource update data. + :param resource_patch_request_body: Workload resource update data. Required. :type resource_patch_request_body: ~azure.mgmt.workloads.models.PatchResourceRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhpWorkloadResource or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + php_workload_name: str, + resource_patch_request_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PhpWorkloadResource: + """Update PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param resource_patch_request_body: Workload resource update data. Required. + :type resource_patch_request_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhpWorkloadResource or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + php_workload_name: str, + resource_patch_request_body: Union[_models.PatchResourceRequestBody, IO], + **kwargs: Any + ) -> _models.PhpWorkloadResource: + """Update PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param resource_patch_request_body: Workload resource update data. Is either a model type or a + IO type. Required. + :type resource_patch_request_body: ~azure.mgmt.workloads.models.PatchResourceRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhpWorkloadResource, or the result of cls(response) + :return: PhpWorkloadResource or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_patch_request_body, 'PatchResourceRequestBody') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_patch_request_body, (IO, bytes)): + _content = resource_patch_request_body + else: + _json = self._serialize.body(resource_patch_request_body, "PatchResourceRequestBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,73 +663,73 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - php_workload_name: str, - delete_infra: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, php_workload_name: str, delete_infra: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, php_workload_name=php_workload_name, - api_version=api_version, + subscription_id=self._config.subscription_id, delete_infra=delete_infra, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - php_workload_name: str, - delete_infra: Optional[str] = None, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, php_workload_name: str, delete_infra: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :param delete_infra: Whether to delete infra along with workload resource. Default value is None. @@ -523,42 +744,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, php_workload_name=php_workload_name, delete_infra=delete_infra, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py index 3840ad9fbc2c..ffe092385a46 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_provider_instances_operations.py @@ -6,101 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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._provider_instances_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._provider_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProviderInstancesOperations: - """ProviderInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`provider_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderInstanceListResult"]: + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ProviderInstance"]: """Gets a list of provider instances in the specified SAP monitor. Gets a list of provider instances in the specified SAP monitor. The operations returns various properties of each provider instances. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderInstanceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.ProviderInstanceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ProviderInstance or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.ProviderInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstanceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstanceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - monitor_name=monitor_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,10 +144,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,61 +156,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any - ) -> "_models.ProviderInstance": + self, resource_group_name: str, monitor_name: str, provider_instance_name: str, **kwargs: Any + ) -> _models.ProviderInstance: """Gets properties of a provider instance. Gets properties of a provider instance for the specified subscription, resource group, SAP monitor name, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param provider_instance_name: Name of the provider instance. + :param provider_instance_name: Name of the provider instance. Required. :type provider_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderInstance, or the result of cls(response) + :return: ProviderInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.ProviderInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,72 +221,171 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore async def _create_initial( self, resource_group_name: str, monitor_name: str, provider_instance_name: str, - provider_instance_parameter: "_models.ProviderInstance", + provider_instance_parameter: Union[_models.ProviderInstance, IO], **kwargs: Any - ) -> "_models.ProviderInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + ) -> _models.ProviderInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(provider_instance_parameter, 'ProviderInstance') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(provider_instance_parameter, (IO, bytes)): + _content = provider_instance_parameter + else: + _json = self._serialize.body(provider_instance_parameter, "ProviderInstance") + + request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: _models.ProviderInstance, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProviderInstance]: + """Creates a provider instance. + Creates a provider instance for the specified subscription, resource group, SAP monitor name, + and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. Required. + :type provider_instance_name: str + :param provider_instance_parameter: Request body representing a provider instance. Required. + :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ProviderInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.ProviderInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProviderInstance]: + """Creates a provider instance. + + Creates a provider instance for the specified subscription, resource group, SAP monitor name, + and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. Required. + :type provider_instance_name: str + :param provider_instance_parameter: Request body representing a provider instance. Required. + :type provider_instance_parameter: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ProviderInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.ProviderInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -263,22 +393,27 @@ async def begin_create( resource_group_name: str, monitor_name: str, provider_instance_name: str, - provider_instance_parameter: "_models.ProviderInstance", + provider_instance_parameter: Union[_models.ProviderInstance, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ProviderInstance"]: + ) -> AsyncLROPoller[_models.ProviderInstance]: """Creates a provider instance. Creates a provider instance for the specified subscription, resource group, SAP monitor name, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param provider_instance_name: Name of the provider instance. + :param provider_instance_name: Name of the provider instance. Required. :type provider_instance_name: str - :param provider_instance_parameter: Request body representing a provider instance. - :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance + :param provider_instance_parameter: Request body representing a provider instance. Is either a + model type or a IO type. Required. + :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -290,120 +425,129 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either ProviderInstance or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.ProviderInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, provider_instance_parameter=provider_instance_parameter, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, monitor_name: str, provider_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResult"]: + self, resource_group_name: str, monitor_name: str, provider_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: """Deletes a provider instance. Deletes a provider instance for the specified subscription, resource group, SAP monitor name, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param provider_instance_name: Name of the provider instance. + :param provider_instance_name: Name of the provider instance. Required. :type provider_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -416,45 +560,50 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_application_server_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_application_server_instances_operations.py index 043d822c2afc..9ce869a593f3 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_application_server_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_application_server_instances_operations.py @@ -6,93 +6,121 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._sap_application_server_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SAPApplicationServerInstancesOperations: - """SAPApplicationServerInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SAPApplicationServerInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`sap_application_server_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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. + 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. + :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. + :param application_instance_name: The name of SAP Application Server instance resource. + Required. :type application_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPApplicationServerInstance, or the result of cls(response) + :return: SAPApplicationServerInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPApplicationServerInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,75 +128,176 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore async def _create_initial( self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.SAPApplicationServerInstance"] = None, + body: Optional[Union[_models.SAPApplicationServerInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPApplicationServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] + ) -> _models.SAPApplicationServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPApplicationServerInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPApplicationServerInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # 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.workloads.models.SAPApplicationServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -176,20 +305,27 @@ async def begin_create( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.SAPApplicationServerInstance"] = None, + body: Optional[Union[_models.SAPApplicationServerInstance, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPApplicationServerInstance"]: - """Puts the SAP Application Server Instance. :code:`
`:code:`
`This will be used by service - only. PUT by end user will return a Bad Request error. + ) -> 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. + :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. + :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 request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPApplicationServerInstance + :param body: The SAP Application Server Instance resource request body. Is either a model type + or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPApplicationServerInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -202,111 +338,219 @@ async def begin_create( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.UpdateSAPApplicationInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPApplicationInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPApplicationServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] + ) -> _models.SAPApplicationServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPApplicationInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPApplicationInstanceRequest") + else: + _json = None - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + @overload + async def begin_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 + ) -> AsyncLROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server 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 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.workloads.models.UpdateSAPApplicationInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -314,19 +558,26 @@ async def begin_update( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.UpdateSAPApplicationInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPApplicationInstanceRequest, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPApplicationServerInstance"]: - """Puts the SAP Application Server Instance. + ) -> AsyncLROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server 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. + :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. + :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 request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPApplicationInstanceRequest + :param body: The SAP Application Server Instance resource request body. Is either a model type + or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPApplicationInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -339,118 +590,129 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - application_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # 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["_models.OperationStatusResult"]: - """Deletes the SAP Application Server Instance. :code:`
`:code:`
`This operation will be - used by service only. Delete by end user will return a Bad Request error. + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """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. + :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. + :param application_instance_name: The name of SAP Application Server instance resource. + Required. :type application_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -463,100 +725,123 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SAPApplicationServerInstanceList"]: - """Lists the SAP Application server Instances in an SVI. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPApplicationServerInstanceList or the result of + :return: An iterator like instance of either SAPApplicationServerInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPApplicationServerInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - sap_virtual_instance_name=sap_virtual_instance_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -570,10 +855,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -584,8 +867,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_central_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_central_instances_operations.py index 8c2fd0f3be64..7006d82b9f49 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_central_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_central_instances_operations.py @@ -6,94 +6,120 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._sap_central_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SAPCentralInstancesOperations: - """SAPCentralInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SAPCentralInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`sap_central_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 Instance. + 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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPCentralServerInstance, or the result of cls(response) + :return: SAPCentralServerInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPCentralServerInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,75 +127,176 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore async def _create_initial( self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.SAPCentralServerInstance"] = None, + body: Optional[Union[_models.SAPCentralServerInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPCentralServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] + ) -> _models.SAPCentralServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPCentralServerInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPCentralServerInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # 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.workloads.models.SAPCentralServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -177,21 +304,27 @@ async def begin_create( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.SAPCentralServerInstance"] = None, + body: Optional[Union[_models.SAPCentralServerInstance, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPCentralServerInstance"]: - """Puts the SAP Central Instance. :code:`
`:code:`
`This will be used by service only. PUT - by end user will return a Bad Request error. + ) -> 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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPCentralServerInstance + :param body: The SAP Central Services Instance request body. Is either a model type or a IO + type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPCentralServerInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -204,111 +337,221 @@ async def begin_create( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.UpdateSAPCentralInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPCentralInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPCentralServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] + ) -> _models.SAPCentralServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPCentralInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPCentralInstanceRequest") + else: + _json = None - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + @overload + async def begin_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 + ) -> AsyncLROPoller[_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.workloads.models.UpdateSAPCentralInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPCentralServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -316,20 +559,27 @@ async def begin_update( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.UpdateSAPCentralInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPCentralInstanceRequest, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPCentralServerInstance"]: - """Updates the SAP Central Instance. :code:`
`:code:`
`This can be used to update tags. + ) -> AsyncLROPoller[_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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPCentralInstanceRequest + :param body: The SAP Central Services Instance resource request body. Is either a model type or + a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPCentralInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -342,119 +592,131 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - central_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # 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["_models.OperationStatusResult"]: - """Deletes the SAP Central Instance. :code:`
`:code:`
`This will be used by service only. - Delete by end user will return a Bad Request error. + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -467,100 +729,123 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SAPCentralInstanceList"]: - """Lists the SAP Central Instances in an SVI. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPCentralInstanceList or the result of + :return: An iterator like instance of either SAPCentralServerInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPCentralInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - sap_virtual_instance_name=sap_virtual_instance_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -574,10 +859,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -588,8 +871,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_database_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_database_instances_operations.py index e13cff2a6c2b..9c5146aa290c 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_database_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_database_instances_operations.py @@ -6,94 +6,120 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._sap_database_instances_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SAPDatabaseInstancesOperations: - """SAPDatabaseInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SAPDatabaseInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`sap_database_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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. + 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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. :type database_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPDatabaseInstance, or the result of cls(response) + :return: SAPDatabaseInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPDatabaseInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,75 +127,176 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore async def _create_initial( self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.SAPDatabaseInstance"] = None, + body: Optional[Union[_models.SAPDatabaseInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPDatabaseInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] + ) -> _models.SAPDatabaseInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPDatabaseInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPDatabaseInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # 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.workloads.models.SAPDatabaseInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -177,21 +304,28 @@ async def begin_create( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.SAPDatabaseInstance"] = None, + body: Optional[Union[_models.SAPDatabaseInstance, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPDatabaseInstance"]: - """Puts the SAP Database Instance. :code:`
`:code:`
`This will be used by service only. PUT - by end user will return a Bad Request error. + ) -> 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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :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: The SAP Database Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPDatabaseInstance + :param body: Request body of Database resource of a SAP system. Is either a model type or a IO + type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPDatabaseInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -203,111 +337,217 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.UpdateSAPDatabaseInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPDatabaseInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPDatabaseInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] + ) -> _models.SAPDatabaseInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPDatabaseInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPDatabaseInstanceRequest") + else: + _json = None - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + + @overload + async def begin_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 + ) -> AsyncLROPoller[_models.SAPDatabaseInstance]: + """Updates the Database 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.workloads.models.UpdateSAPDatabaseInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SAPDatabaseInstance]: + """Updates the Database 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -315,20 +555,26 @@ async def begin_update( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.UpdateSAPDatabaseInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPDatabaseInstanceRequest, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPDatabaseInstance"]: - """Puts the SAP Database Instance. + ) -> AsyncLROPoller[_models.SAPDatabaseInstance]: + """Updates the Database 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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :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: The SAP Database Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPDatabaseInstanceRequest + :param body: Database resource update request body. Is either a model type or a IO type. + Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPDatabaseInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -340,119 +586,130 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either SAPDatabaseInstance or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - database_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # 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["_models.OperationStatusResult"]: - """Deletes the SAP Database Instance. :code:`
`:code:`
`This will be used by service only. - Delete by end user will return a Bad Request error. + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. :type database_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -465,100 +722,121 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SAPDatabaseInstanceList"]: - """Lists the SAP Database Instances in an SVI. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPDatabaseInstanceList or the result of - cls(response) + :return: An iterator like instance of either SAPDatabaseInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPDatabaseInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - sap_virtual_instance_name=sap_virtual_instance_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -572,10 +850,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -586,8 +862,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_virtual_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_virtual_instances_operations.py index da0c4c108042..8b53fb616b43 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_virtual_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_sap_virtual_instances_operations.py @@ -6,121 +6,240 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_start_request_initial, build_stop_request_initial, build_update_request -T = TypeVar('T') +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 WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SAPVirtualInstancesOperations: - """SAPVirtualInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SAPVirtualInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`sap_virtual_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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["_models.SAPVirtualInstance"] = None, + body: Optional[Union[_models.SAPVirtualInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPVirtualInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] + ) -> _models.SAPVirtualInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPVirtualInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPVirtualInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # 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.workloads.models.SAPVirtualInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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["_models.SAPVirtualInstance"] = None, + body: Optional[Union[_models.SAPVirtualInstance, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SAPVirtualInstance"]: - """Creates an Virtual Instance for SAP. + ) -> 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. + :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 request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPVirtualInstance + :param body: Virtual Instance for SAP solutions resource request body. Is either a model type + or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPVirtualInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -132,93 +251,108 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either SAPVirtualInstance or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.SAPVirtualInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> "_models.SAPVirtualInstance": - """Gets an Virtual Instance for SAP. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPVirtualInstance, or the result of cls(response) + :return: SAPVirtualInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -226,68 +360,149 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.UpdateSAPVirtualInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _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.workloads.models.UpdateSAPVirtualInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, sap_virtual_instance_name: str, - body: Optional["_models.UpdateSAPVirtualInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPVirtualInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPVirtualInstance": - """Updates an Virtual Instance for SAP. + ) -> _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. + :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 Update Virtual Instance for SAP request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPVirtualInstanceRequest + :param body: Request body to update a Virtual Instance for SAP solutions resource. Is either a + model type or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPVirtualInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPVirtualInstance, or the result of cls(response) + :return: SAPVirtualInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPVirtualInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPVirtualInstanceRequest") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -295,76 +510,80 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResult"]: - """Deletes an Virtual Instance for SAP. + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -377,94 +596,116 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SAPVirtualInstanceList"]: - """Gets all Virtual Instances for SAP in a 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPVirtualInstanceList or the result of - cls(response) + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -478,10 +719,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -492,53 +731,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SAPVirtualInstanceList"]: - """Gets all Virtual Instances for SAP in the subscription. + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SAPVirtualInstance"]: + """Gets all Virtual Instances for SAP solutions resources in a Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPVirtualInstanceList or the result of - cls(response) + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,10 +802,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -566,72 +814,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore async def _start_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore @distributed_trace_async async def begin_start( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResult"]: - """Starts the SAP System. + self, resource_group_name: str, sap_virtual_instance_name: str, **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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -644,120 +895,229 @@ async def begin_start( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore async def _stop_initial( self, resource_group_name: str, sap_virtual_instance_name: str, - body: Optional["_models.StopRequest"] = None, + body: Optional[Union[_models.StopRequest, IO]] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'StopRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._stop_initial.metadata['url'], + content=_content, + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # type: ignore + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # 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.workloads.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.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["_models.StopRequest"] = None, + body: Optional[Union[_models.StopRequest, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResult"]: - """Stops the SAP System. + ) -> 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. + :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 Instances for SAP stop request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.StopRequest + :param body: The Virtual Instance for SAP solutions resource stop request body. Is either a + model type or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.StopRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -769,47 +1129,55 @@ async def begin_stop( :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_skus_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_skus_operations.py index 9096a0722626..e624a3cc83fe 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_skus_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_skus_operations.py @@ -6,83 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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._skus_operations import build_list_request -T = TypeVar('T') +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.SkusListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuDefinition"]: """Lists all the available SKUs under this PR. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkusListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SkusListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.SkuDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SkusListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkusListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,10 +124,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/skus"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_wordpress_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_wordpress_instances_operations.py index 1d833807b0f7..b9ddcbddc2d7 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_wordpress_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_wordpress_instances_operations.py @@ -6,98 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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._wordpress_instances_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._wordpress_instances_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._vendor import WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WordpressInstancesOperations: - """WordpressInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WordpressInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.aio.WorkloadsClient`'s + :attr:`wordpress_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WordpressInstanceResourceList"]: + self, resource_group_name: str, php_workload_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WordpressInstanceResource"]: """Lists WordPress instance resources under a phpWorkload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WordpressInstanceResourceList or the result of + :return: An iterator like instance of either WordpressInstanceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.WordpressInstanceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.workloads.models.WordpressInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - php_workload_name=php_workload_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,10 +143,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,54 +155,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any - ) -> "_models.WordpressInstanceResource": + self, resource_group_name: str, php_workload_name: str, **kwargs: Any + ) -> _models.WordpressInstanceResource: """Gets the WordPress instance resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WordpressInstanceResource, or the result of cls(response) + :return: WordpressInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.WordpressInstanceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,87 +214,181 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, php_workload_name: str, - wordpress_instance_resource: "_models.WordpressInstanceResource", + wordpress_instance_resource: Union[_models.WordpressInstanceResource, IO], **kwargs: Any - ) -> "_models.WordpressInstanceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResource"] + ) -> _models.WordpressInstanceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(wordpress_instance_resource, 'WordpressInstanceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(wordpress_instance_resource, (IO, bytes)): + _content = wordpress_instance_resource + else: + _json = self._serialize.body(wordpress_instance_resource, "WordpressInstanceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + wordpress_instance_resource: _models.WordpressInstanceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WordpressInstanceResource]: + """Create or updated WordPress instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param wordpress_instance_resource: Resource create or update request payload. Required. + :type wordpress_instance_resource: ~azure.mgmt.workloads.models.WordpressInstanceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WordpressInstanceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.WordpressInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + wordpress_instance_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WordpressInstanceResource]: + """Create or updated WordPress instance resource. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param wordpress_instance_resource: Resource create or update request payload. Required. + :type wordpress_instance_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WordpressInstanceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.WordpressInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, php_workload_name: str, - wordpress_instance_resource: "_models.WordpressInstanceResource", + wordpress_instance_resource: Union[_models.WordpressInstanceResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WordpressInstanceResource"]: + ) -> AsyncLROPoller[_models.WordpressInstanceResource]: """Create or updated WordPress instance resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str - :param wordpress_instance_resource: Resource create or update request payload. - :type wordpress_instance_resource: ~azure.mgmt.workloads.models.WordpressInstanceResource + :param wordpress_instance_resource: Resource create or update request payload. Is either a + model type or a IO type. Required. + :type wordpress_instance_resource: ~azure.mgmt.workloads.models.WordpressInstanceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -273,93 +401,107 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.workloads.models.WordpressInstanceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, php_workload_name=php_workload_name, wordpress_instance_resource=wordpress_instance_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any + self, resource_group_name: str, php_workload_name: str, **kwargs: Any ) -> None: """Delete WordPress instance resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -370,5 +512,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_workloads_client_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_workloads_client_operations.py index 205822951ef8..ac6c51a91b76 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_workloads_client_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/aio/operations/_workloads_client_operations.py @@ -6,72 +6,165 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +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_client_operations import build_sap_availability_zone_details_request, build_sap_disk_configurations_request, build_sap_sizing_recommendations_request, build_sap_supported_sku_request -T = TypeVar('T') +from ...operations._workloads_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 WorkloadsClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkloadsClientOperationsMixin: - @distributed_trace_async +class WorkloadsClientOperationsMixin(WorkloadsClientMixinABC): + @overload async def sap_sizing_recommendations( self, location: str, - sap_sizing_recommendation: Optional["_models.SAPSizingRecommendationRequest"] = None, + sap_sizing_recommendation: Optional[_models.SAPSizingRecommendationRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPSizingRecommendationResult": - """Get SAP sizing recommendations. + ) -> _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. + :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.workloads.models.SAPSizingRecommendationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPSizingRecommendationResult, or the result of cls(response) + :return: SAPSizingRecommendationResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPSizingRecommendationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPSizingRecommendationResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[Union[_models.SAPSizingRecommendationRequest, IO]] = None, + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. - if sap_sizing_recommendation is not None: - _json = self._serialize.body(sap_sizing_recommendation, 'SAPSizingRecommendationRequest') + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Is either a model + type or a IO type. Default value is None. + :type sap_sizing_recommendation: ~azure.mgmt.workloads.models.SAPSizingRecommendationRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPSizingRecommendationResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_sizing_recommendation, (IO, bytes)): + _content = sap_sizing_recommendation else: - _json = None + if sap_sizing_recommendation is not None: + _json = self._serialize.body(sap_sizing_recommendation, "SAPSizingRecommendationRequest") + else: + _json = None request = build_sap_sizing_recommendations_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_sizing_recommendations.metadata['url'], + content=_content, + template_url=self.sap_sizing_recommendations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -79,64 +172,131 @@ async def sap_sizing_recommendations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPSizingRecommendationResult', pipeline_response) + deserialized = self._deserialize("SAPSizingRecommendationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_sizing_recommendations.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSizingRecommendations"} # type: ignore + sap_sizing_recommendations.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSizingRecommendations"} # type: ignore - - @distributed_trace_async + @overload async def sap_supported_sku( self, location: str, - sap_supported_sku: Optional["_models.SAPSupportedSkusRequest"] = None, + sap_supported_sku: Optional[_models.SAPSupportedSkusRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPSupportedResourceSkusResult": - """Get SAP supported SKUs. + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. - :param location: The name of Azure region. + :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.workloads.models.SAPSupportedSkusRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPSupportedResourceSkusResult, or the result of cls(response) + :return: SAPSupportedResourceSkusResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPSupportedResourceSkusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPSupportedResourceSkusResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[Union[_models.SAPSupportedSkusRequest, IO]] = None, + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. - if sap_supported_sku is not None: - _json = self._serialize.body(sap_supported_sku, 'SAPSupportedSkusRequest') + :param location: The name of Azure region. Required. + :type location: str + :param sap_supported_sku: SAP Supported SKU Request body. Is either a model type or a IO type. + Default value is None. + :type sap_supported_sku: ~azure.mgmt.workloads.models.SAPSupportedSkusRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPSupportedResourceSkusResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_supported_sku, (IO, bytes)): + _content = sap_supported_sku else: - _json = None + if sap_supported_sku is not None: + _json = self._serialize.body(sap_supported_sku, "SAPSupportedSkusRequest") + else: + _json = None request = build_sap_supported_sku_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_supported_sku.metadata['url'], + content=_content, + template_url=self.sap_supported_sku.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,64 +304,131 @@ async def sap_supported_sku( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPSupportedResourceSkusResult', pipeline_response) + deserialized = self._deserialize("SAPSupportedResourceSkusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_supported_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSapSupportedSku"} # type: ignore - + sap_supported_sku.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSapSupportedSku"} # type: ignore - @distributed_trace_async + @overload async def sap_disk_configurations( self, location: str, - sap_disk_configurations: Optional["_models.SAPDiskConfigurationsRequest"] = None, + sap_disk_configurations: Optional[_models.SAPDiskConfigurationsRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPDiskConfigurationsResult": - """Get SAP Disk Configurations. + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. - :param location: The name of Azure region. + :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.workloads.models.SAPDiskConfigurationsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPDiskConfigurationsResult, or the result of cls(response) + :return: SAPDiskConfigurationsResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPDiskConfigurationsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDiskConfigurationsResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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]] = None, + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. - if sap_disk_configurations is not None: - _json = self._serialize.body(sap_disk_configurations, 'SAPDiskConfigurationsRequest') + :param location: The name of Azure region. Required. + :type location: str + :param sap_disk_configurations: SAP Disk Configurations Request body. Is either a model type or + a IO type. Default value is None. + :type sap_disk_configurations: ~azure.mgmt.workloads.models.SAPDiskConfigurationsRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDiskConfigurationsResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_disk_configurations, (IO, bytes)): + _content = sap_disk_configurations else: - _json = None + if sap_disk_configurations is not None: + _json = self._serialize.body(sap_disk_configurations, "SAPDiskConfigurationsRequest") + else: + _json = None request = build_sap_disk_configurations_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_disk_configurations.metadata['url'], + content=_content, + template_url=self.sap_disk_configurations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,66 +436,135 @@ async def sap_disk_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPDiskConfigurationsResult', pipeline_response) + deserialized = self._deserialize("SAPDiskConfigurationsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_disk_configurations.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getDiskConfigurations"} # type: ignore - + sap_disk_configurations.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getDiskConfigurations"} # type: ignore - @distributed_trace_async + @overload async def sap_availability_zone_details( self, location: str, - sap_availability_zone_details: Optional["_models.SAPAvailabilityZoneDetailsRequest"] = None, + sap_availability_zone_details: Optional[_models.SAPAvailabilityZoneDetailsRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPAvailabilityZoneDetailsResult": - """Get SAP Availability Zone Details. + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. - :param location: The name of Azure 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.workloads.models.SAPAvailabilityZoneDetailsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPAvailabilityZoneDetailsResult, or the result of cls(response) + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPAvailabilityZoneDetailsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPAvailabilityZoneDetailsResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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]] = None, + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. - if sap_availability_zone_details is not None: - _json = self._serialize.body(sap_availability_zone_details, 'SAPAvailabilityZoneDetailsRequest') + :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 + model type or a IO type. Default value is None. + :type sap_availability_zone_details: + ~azure.mgmt.workloads.models.SAPAvailabilityZoneDetailsRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPAvailabilityZoneDetailsResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_availability_zone_details, (IO, bytes)): + _content = sap_availability_zone_details else: - _json = None + 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( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_availability_zone_details.metadata['url'], + content=_content, + template_url=self.sap_availability_zone_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -276,12 +572,11 @@ async def sap_availability_zone_details( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPAvailabilityZoneDetailsResult', pipeline_response) + deserialized = self._deserialize("SAPAvailabilityZoneDetailsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_availability_zone_details.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails"} # type: ignore - + sap_availability_zone_details.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py index 232cc6f9e567..c8c2f62739f7 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/__init__.py @@ -28,6 +28,7 @@ from ._models_py3 import ErrorDetail from ._models_py3 import ErrorInnerError from ._models_py3 import ErrorResponse +from ._models_py3 import ExternalInstallationSoftwareConfiguration from ._models_py3 import FileshareProfile from ._models_py3 import GatewayServerProperties from ._models_py3 import HanaDbProviderInstanceProperties @@ -134,234 +135,237 @@ from ._models_py3 import WordpressInstanceResource from ._models_py3 import WordpressInstanceResourceList - -from ._workloads_client_enums import ( - ActionType, - ApplicationProvisioningState, - AzureFrontDoorEnabled, - CentralServerVirtualMachineType, - CreatedByType, - DatabaseTier, - DatabaseType, - DiskStorageType, - EnableBackup, - EnableSslEnforcement, - EnqueueReplicationServerType, - FileShareStorageType, - FileShareType, - HAEnabled, - LoadBalancerType, - LocationType, - ManagedServiceIdentityType, - OSImageOffer, - OSImagePublisher, - OSImageSku, - OSImageVersion, - OSType, - OperationProperties, - Origin, - PHPVersion, - PhpWorkloadProvisioningState, - RedisCacheFamily, - RoutingPreference, - SAPConfigurationType, - SAPDatabaseScaleMethod, - SAPDatabaseType, - SAPDeploymentType, - SAPEnvironmentType, - SAPHealthState, - SAPHighAvailabilityType, - SAPProductType, - SAPSoftwareInstallationType, - SAPVirtualInstanceState, - SAPVirtualInstanceStatus, - SapVirtualInstanceProvisioningState, - SearchType, - SkuRestrictionReasonCode, - SkuRestrictionType, - SkuScaleType, - SkuTier, - WordpressVersions, - WorkloadKind, - WorkloadMonitorActionType, - WorkloadMonitorProvisioningState, -) +from ._workloads_client_enums import ActionType +from ._workloads_client_enums import ApplicationProvisioningState +from ._workloads_client_enums import AzureFrontDoorEnabled +from ._workloads_client_enums import CentralServerVirtualMachineType +from ._workloads_client_enums import CreatedByType +from ._workloads_client_enums import DatabaseTier +from ._workloads_client_enums import DatabaseType +from ._workloads_client_enums import DiskStorageType +from ._workloads_client_enums import EnableBackup +from ._workloads_client_enums import EnableSslEnforcement +from ._workloads_client_enums import EnqueueReplicationServerType +from ._workloads_client_enums import FileShareStorageType +from ._workloads_client_enums import FileShareType +from ._workloads_client_enums import HAEnabled +from ._workloads_client_enums import LoadBalancerType +from ._workloads_client_enums import LocationType +from ._workloads_client_enums import ManagedServiceIdentityType +from ._workloads_client_enums import OSImageOffer +from ._workloads_client_enums import OSImagePublisher +from ._workloads_client_enums import OSImageSku +from ._workloads_client_enums import OSImageVersion +from ._workloads_client_enums import OSType +from ._workloads_client_enums import OperationProperties +from ._workloads_client_enums import Origin +from ._workloads_client_enums import PHPVersion +from ._workloads_client_enums import PhpWorkloadProvisioningState +from ._workloads_client_enums import RedisCacheFamily +from ._workloads_client_enums import RoutingPreference +from ._workloads_client_enums import SAPConfigurationType +from ._workloads_client_enums import SAPDatabaseScaleMethod +from ._workloads_client_enums import SAPDatabaseType +from ._workloads_client_enums import SAPDeploymentType +from ._workloads_client_enums import SAPEnvironmentType +from ._workloads_client_enums import SAPHealthState +from ._workloads_client_enums import SAPHighAvailabilityType +from ._workloads_client_enums import SAPProductType +from ._workloads_client_enums import SAPSoftwareInstallationType +from ._workloads_client_enums import SAPVirtualInstanceState +from ._workloads_client_enums import SAPVirtualInstanceStatus +from ._workloads_client_enums import SapVirtualInstanceProvisioningState +from ._workloads_client_enums import SearchType +from ._workloads_client_enums import SkuRestrictionReasonCode +from ._workloads_client_enums import SkuRestrictionType +from ._workloads_client_enums import SkuScaleType +from ._workloads_client_enums import SkuTier +from ._workloads_client_enums import WordpressVersions +from ._workloads_client_enums import WorkloadKind +from ._workloads_client_enums import WorkloadMonitorActionType +from ._workloads_client_enums import WorkloadMonitorProvisioningState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ApplicationServerConfiguration', - 'BackupProfile', - 'CacheProfile', - 'CentralServerConfiguration', - 'CentralServerVmDetails', - 'DB2ProviderInstanceProperties', - 'DatabaseConfiguration', - 'DatabaseProfile', - 'DatabaseVmDetails', - 'DeployerVmPackages', - 'DeploymentConfiguration', - 'DeploymentWithOSConfiguration', - 'DiscoveryConfiguration', - 'DiskInfo', - 'EnqueueReplicationServerProperties', - 'EnqueueServerProperties', - 'Error', - 'ErrorAdditionalInfo', - 'ErrorDefinition', - 'ErrorDetail', - 'ErrorInnerError', - 'ErrorResponse', - 'FileshareProfile', - 'GatewayServerProperties', - 'HanaDbProviderInstanceProperties', - 'HighAvailabilityConfiguration', - 'HighAvailabilitySoftwareConfiguration', - 'ImageReference', - 'InfrastructureConfiguration', - 'LinuxConfiguration', - 'ManagedRGConfiguration', - 'MessageServerProperties', - 'Monitor', - 'MonitorListResult', - 'MonitorPropertiesErrors', - 'MsSqlServerProviderInstanceProperties', - 'NetworkConfiguration', - 'NetworkProfile', - 'NodeProfile', - 'OSConfiguration', - 'OSProfile', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'OperationStatusResult', - 'OperationsContent', - 'OperationsDefinition', - 'OperationsDefinitionArrayResponseWithContinuation', - 'OperationsDefinitionDisplay', - 'OperationsDisplayDefinition', - 'OsImageProfile', - 'OsSapConfiguration', - 'PatchResourceRequestBody', - 'PatchResourceRequestBodyIdentity', - 'PhpProfile', - 'PhpWorkloadResource', - 'PhpWorkloadResourceIdentity', - 'PhpWorkloadResourceList', - 'PrometheusHaClusterProviderInstanceProperties', - 'PrometheusOSProviderInstanceProperties', - 'ProviderInstance', - 'ProviderInstanceListResult', - 'ProviderInstancePropertiesErrors', - 'ProviderSpecificProperties', - 'ProxyResource', - 'Resource', - 'RestrictionInfo', - 'SAPApplicationServerInstance', - 'SAPApplicationServerInstanceList', - 'SAPAvailabilityZoneDetailsRequest', - 'SAPAvailabilityZoneDetailsResult', - 'SAPAvailabilityZonePair', - 'SAPCentralInstanceList', - 'SAPCentralServerInstance', - 'SAPConfiguration', - 'SAPDatabaseInstance', - 'SAPDatabaseInstanceList', - 'SAPDiskConfiguration', - 'SAPDiskConfigurationsRequest', - 'SAPDiskConfigurationsResult', - 'SAPInstallWithoutOSConfigSoftwareConfiguration', - 'SAPSizingRecommendationRequest', - 'SAPSizingRecommendationResult', - 'SAPSupportedResourceSkusResult', - 'SAPSupportedSku', - 'SAPSupportedSkusRequest', - 'SAPVirtualInstance', - 'SAPVirtualInstanceError', - 'SAPVirtualInstanceList', - 'SapNetWeaverProviderInstanceProperties', - 'SearchProfile', - 'ServiceInitiatedSoftwareConfiguration', - 'SingleServerConfiguration', - 'SingleServerRecommendationResult', - 'SiteProfile', - 'Sku', - 'SkuCapability', - 'SkuCapacity', - 'SkuCost', - 'SkuDefinition', - 'SkuLocationAndZones', - 'SkuRestriction', - 'SkuZoneDetail', - 'SkusListResult', - 'SoftwareConfiguration', - 'SshConfiguration', - 'SshKeyPair', - 'SshPublicKey', - 'StopRequest', - 'SystemData', - 'Tags', - 'ThreeTierConfiguration', - 'ThreeTierRecommendationResult', - 'TrackedResource', - 'UpdateMonitorRequest', - 'UpdateSAPApplicationInstanceRequest', - 'UpdateSAPCentralInstanceRequest', - 'UpdateSAPDatabaseInstanceRequest', - 'UpdateSAPVirtualInstanceRequest', - 'UserAssignedIdentity', - 'UserAssignedServiceIdentity', - 'UserProfile', - 'VirtualMachineConfiguration', - 'VmssNodesProfile', - 'WindowsConfiguration', - 'WordpressInstanceResource', - 'WordpressInstanceResourceList', - 'ActionType', - 'ApplicationProvisioningState', - 'AzureFrontDoorEnabled', - 'CentralServerVirtualMachineType', - 'CreatedByType', - 'DatabaseTier', - 'DatabaseType', - 'DiskStorageType', - 'EnableBackup', - 'EnableSslEnforcement', - 'EnqueueReplicationServerType', - 'FileShareStorageType', - 'FileShareType', - 'HAEnabled', - 'LoadBalancerType', - 'LocationType', - 'ManagedServiceIdentityType', - 'OSImageOffer', - 'OSImagePublisher', - 'OSImageSku', - 'OSImageVersion', - 'OSType', - 'OperationProperties', - 'Origin', - 'PHPVersion', - 'PhpWorkloadProvisioningState', - 'RedisCacheFamily', - 'RoutingPreference', - 'SAPConfigurationType', - 'SAPDatabaseScaleMethod', - 'SAPDatabaseType', - 'SAPDeploymentType', - 'SAPEnvironmentType', - 'SAPHealthState', - 'SAPHighAvailabilityType', - 'SAPProductType', - 'SAPSoftwareInstallationType', - 'SAPVirtualInstanceState', - 'SAPVirtualInstanceStatus', - 'SapVirtualInstanceProvisioningState', - 'SearchType', - 'SkuRestrictionReasonCode', - 'SkuRestrictionType', - 'SkuScaleType', - 'SkuTier', - 'WordpressVersions', - 'WorkloadKind', - 'WorkloadMonitorActionType', - 'WorkloadMonitorProvisioningState', + "ApplicationServerConfiguration", + "BackupProfile", + "CacheProfile", + "CentralServerConfiguration", + "CentralServerVmDetails", + "DB2ProviderInstanceProperties", + "DatabaseConfiguration", + "DatabaseProfile", + "DatabaseVmDetails", + "DeployerVmPackages", + "DeploymentConfiguration", + "DeploymentWithOSConfiguration", + "DiscoveryConfiguration", + "DiskInfo", + "EnqueueReplicationServerProperties", + "EnqueueServerProperties", + "Error", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDetail", + "ErrorInnerError", + "ErrorResponse", + "ExternalInstallationSoftwareConfiguration", + "FileshareProfile", + "GatewayServerProperties", + "HanaDbProviderInstanceProperties", + "HighAvailabilityConfiguration", + "HighAvailabilitySoftwareConfiguration", + "ImageReference", + "InfrastructureConfiguration", + "LinuxConfiguration", + "ManagedRGConfiguration", + "MessageServerProperties", + "Monitor", + "MonitorListResult", + "MonitorPropertiesErrors", + "MsSqlServerProviderInstanceProperties", + "NetworkConfiguration", + "NetworkProfile", + "NodeProfile", + "OSConfiguration", + "OSProfile", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationStatusResult", + "OperationsContent", + "OperationsDefinition", + "OperationsDefinitionArrayResponseWithContinuation", + "OperationsDefinitionDisplay", + "OperationsDisplayDefinition", + "OsImageProfile", + "OsSapConfiguration", + "PatchResourceRequestBody", + "PatchResourceRequestBodyIdentity", + "PhpProfile", + "PhpWorkloadResource", + "PhpWorkloadResourceIdentity", + "PhpWorkloadResourceList", + "PrometheusHaClusterProviderInstanceProperties", + "PrometheusOSProviderInstanceProperties", + "ProviderInstance", + "ProviderInstanceListResult", + "ProviderInstancePropertiesErrors", + "ProviderSpecificProperties", + "ProxyResource", + "Resource", + "RestrictionInfo", + "SAPApplicationServerInstance", + "SAPApplicationServerInstanceList", + "SAPAvailabilityZoneDetailsRequest", + "SAPAvailabilityZoneDetailsResult", + "SAPAvailabilityZonePair", + "SAPCentralInstanceList", + "SAPCentralServerInstance", + "SAPConfiguration", + "SAPDatabaseInstance", + "SAPDatabaseInstanceList", + "SAPDiskConfiguration", + "SAPDiskConfigurationsRequest", + "SAPDiskConfigurationsResult", + "SAPInstallWithoutOSConfigSoftwareConfiguration", + "SAPSizingRecommendationRequest", + "SAPSizingRecommendationResult", + "SAPSupportedResourceSkusResult", + "SAPSupportedSku", + "SAPSupportedSkusRequest", + "SAPVirtualInstance", + "SAPVirtualInstanceError", + "SAPVirtualInstanceList", + "SapNetWeaverProviderInstanceProperties", + "SearchProfile", + "ServiceInitiatedSoftwareConfiguration", + "SingleServerConfiguration", + "SingleServerRecommendationResult", + "SiteProfile", + "Sku", + "SkuCapability", + "SkuCapacity", + "SkuCost", + "SkuDefinition", + "SkuLocationAndZones", + "SkuRestriction", + "SkuZoneDetail", + "SkusListResult", + "SoftwareConfiguration", + "SshConfiguration", + "SshKeyPair", + "SshPublicKey", + "StopRequest", + "SystemData", + "Tags", + "ThreeTierConfiguration", + "ThreeTierRecommendationResult", + "TrackedResource", + "UpdateMonitorRequest", + "UpdateSAPApplicationInstanceRequest", + "UpdateSAPCentralInstanceRequest", + "UpdateSAPDatabaseInstanceRequest", + "UpdateSAPVirtualInstanceRequest", + "UserAssignedIdentity", + "UserAssignedServiceIdentity", + "UserProfile", + "VirtualMachineConfiguration", + "VmssNodesProfile", + "WindowsConfiguration", + "WordpressInstanceResource", + "WordpressInstanceResourceList", + "ActionType", + "ApplicationProvisioningState", + "AzureFrontDoorEnabled", + "CentralServerVirtualMachineType", + "CreatedByType", + "DatabaseTier", + "DatabaseType", + "DiskStorageType", + "EnableBackup", + "EnableSslEnforcement", + "EnqueueReplicationServerType", + "FileShareStorageType", + "FileShareType", + "HAEnabled", + "LoadBalancerType", + "LocationType", + "ManagedServiceIdentityType", + "OSImageOffer", + "OSImagePublisher", + "OSImageSku", + "OSImageVersion", + "OSType", + "OperationProperties", + "Origin", + "PHPVersion", + "PhpWorkloadProvisioningState", + "RedisCacheFamily", + "RoutingPreference", + "SAPConfigurationType", + "SAPDatabaseScaleMethod", + "SAPDatabaseType", + "SAPDeploymentType", + "SAPEnvironmentType", + "SAPHealthState", + "SAPHighAvailabilityType", + "SAPProductType", + "SAPSoftwareInstallationType", + "SAPVirtualInstanceState", + "SAPVirtualInstanceStatus", + "SapVirtualInstanceProvisioningState", + "SearchType", + "SkuRestrictionReasonCode", + "SkuRestrictionType", + "SkuScaleType", + "SkuTier", + "WordpressVersions", + "WorkloadKind", + "WorkloadMonitorActionType", + "WorkloadMonitorProvisioningState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py index 204f44536439..820d7dc36c5e 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_models_py3.py @@ -1,4 +1,5 @@ # 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. @@ -7,105 +8,108 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._workloads_client_enums import * +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ApplicationServerConfiguration(msrest.serialization.Model): + +class ApplicationServerConfiguration(_serialization.Model): """Gets or sets the application server configuration. All required parameters must be populated in order to send to Azure. - :ivar subnet_id: Required. The subnet id. + :ivar subnet_id: The subnet id. Required. :vartype subnet_id: str - :ivar virtual_machine_configuration: Required. Gets or sets the virtual machine configuration. + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. :vartype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration - :ivar instance_count: Required. The number of app server instances. - :vartype instance_count: long + :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}, + "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': 'long'}, + "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: "VirtualMachineConfiguration", + virtual_machine_configuration: "_models.VirtualMachineConfiguration", instance_count: int, **kwargs ): """ - :keyword subnet_id: Required. The subnet id. + :keyword subnet_id: The subnet id. Required. :paramtype subnet_id: str - :keyword virtual_machine_configuration: Required. Gets or sets the virtual machine - configuration. + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. :paramtype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration - :keyword instance_count: Required. The number of app server instances. - :paramtype instance_count: long + :keyword instance_count: The number of app server instances. Required. + :paramtype instance_count: int """ - super(ApplicationServerConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet_id = subnet_id self.virtual_machine_configuration = virtual_machine_configuration self.instance_count = instance_count -class BackupProfile(msrest.serialization.Model): +class BackupProfile(_serialization.Model): """Backup profile. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar backup_enabled: Required. Whether to enable Azure backup for the workload. Possible - values include: "Enabled", "Disabled". + :ivar backup_enabled: Whether to enable Azure backup for the workload. Required. Known values + are: "Enabled" and "Disabled". :vartype backup_enabled: str or ~azure.mgmt.workloads.models.EnableBackup :ivar vault_resource_id: Backup vault resource Id. :vartype vault_resource_id: str """ _validation = { - 'backup_enabled': {'required': True}, - 'vault_resource_id': {'readonly': True}, + "backup_enabled": {"required": True}, + "vault_resource_id": {"readonly": True}, } _attribute_map = { - 'backup_enabled': {'key': 'backupEnabled', 'type': 'str'}, - 'vault_resource_id': {'key': 'vaultResourceId', 'type': 'str'}, + "backup_enabled": {"key": "backupEnabled", "type": "str"}, + "vault_resource_id": {"key": "vaultResourceId", "type": "str"}, } - def __init__( - self, - *, - backup_enabled: Union[str, "EnableBackup"], - **kwargs - ): + def __init__(self, *, backup_enabled: Union[str, "_models.EnableBackup"], **kwargs): """ - :keyword backup_enabled: Required. Whether to enable Azure backup for the workload. Possible - values include: "Enabled", "Disabled". + :keyword backup_enabled: Whether to enable Azure backup for the workload. Required. Known + values are: "Enabled" and "Disabled". :paramtype backup_enabled: str or ~azure.mgmt.workloads.models.EnableBackup """ - super(BackupProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.backup_enabled = backup_enabled self.vault_resource_id = None -class CacheProfile(msrest.serialization.Model): +class CacheProfile(_serialization.Model): """Cache profile. Variables are only populated by the server, and will be ignored when sending a request. @@ -114,36 +118,36 @@ class CacheProfile(msrest.serialization.Model): :ivar name: Cache name. :vartype name: str - :ivar sku_name: Required. Cache SKU name. + :ivar sku_name: Cache SKU name. Required. :vartype sku_name: str - :ivar family: Required. Cache family. Possible values include: "C", "P". + :ivar family: Cache family. Required. Known values are: "C" and "P". :vartype family: str or ~azure.mgmt.workloads.models.RedisCacheFamily - :ivar capacity: Required. Cache capacity. - :vartype capacity: long + :ivar capacity: Cache capacity. Required. + :vartype capacity: int :ivar cache_resource_id: Cache resource Id. :vartype cache_resource_id: str """ _validation = { - 'sku_name': {'required': True}, - 'family': {'required': True}, - 'capacity': {'required': True}, - 'cache_resource_id': {'readonly': True}, + "sku_name": {"required": True}, + "family": {"required": True}, + "capacity": {"required": True}, + "cache_resource_id": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'sku_name': {'key': 'skuName', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - 'cache_resource_id': {'key': 'cacheResourceId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "sku_name": {"key": "skuName", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + "cache_resource_id": {"key": "cacheResourceId", "type": "str"}, } def __init__( self, *, sku_name: str, - family: Union[str, "RedisCacheFamily"], + family: Union[str, "_models.RedisCacheFamily"], capacity: int, name: Optional[str] = None, **kwargs @@ -151,14 +155,14 @@ def __init__( """ :keyword name: Cache name. :paramtype name: str - :keyword sku_name: Required. Cache SKU name. + :keyword sku_name: Cache SKU name. Required. :paramtype sku_name: str - :keyword family: Required. Cache family. Possible values include: "C", "P". + :keyword family: Cache family. Required. Known values are: "C" and "P". :paramtype family: str or ~azure.mgmt.workloads.models.RedisCacheFamily - :keyword capacity: Required. Cache capacity. - :paramtype capacity: long + :keyword capacity: Cache capacity. Required. + :paramtype capacity: int """ - super(CacheProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.sku_name = sku_name self.family = family @@ -166,249 +170,245 @@ def __init__( self.cache_resource_id = None -class CentralServerConfiguration(msrest.serialization.Model): +class CentralServerConfiguration(_serialization.Model): """Gets or sets the central server configuration. All required parameters must be populated in order to send to Azure. - :ivar subnet_id: Required. The subnet id. + :ivar subnet_id: The subnet id. Required. :vartype subnet_id: str - :ivar virtual_machine_configuration: Required. Gets or sets the virtual machine configuration. + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. :vartype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration - :ivar instance_count: Required. The number of central server VMs. - :vartype instance_count: long + :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}, + "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': 'long'}, + "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: "VirtualMachineConfiguration", + virtual_machine_configuration: "_models.VirtualMachineConfiguration", instance_count: int, **kwargs ): """ - :keyword subnet_id: Required. The subnet id. + :keyword subnet_id: The subnet id. Required. :paramtype subnet_id: str - :keyword virtual_machine_configuration: Required. Gets or sets the virtual machine - configuration. + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. :paramtype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration - :keyword instance_count: Required. The number of central server VMs. - :paramtype instance_count: long + :keyword instance_count: The number of central server VMs. Required. + :paramtype instance_count: int """ - super(CentralServerConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet_id = subnet_id self.virtual_machine_configuration = virtual_machine_configuration self.instance_count = instance_count -class CentralServerVmDetails(msrest.serialization.Model): - """The Central Server VM Details. +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. Possible values include: "Primary", - "Secondary", "Unknown", "ASCS", "ERSInactive", "ERS", "Standby". + :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.workloads.models.CentralServerVirtualMachineType :ivar virtual_machine_id: :vartype virtual_machine_id: str """ _validation = { - 'type': {'readonly': True}, - 'virtual_machine_id': {'readonly': True}, + "type": {"readonly": True}, + "virtual_machine_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'virtual_machine_id': {'key': 'virtualMachineId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CentralServerVmDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.virtual_machine_id = None -class DatabaseConfiguration(msrest.serialization.Model): +class DatabaseConfiguration(_serialization.Model): """Gets or sets the database configuration. All required parameters must be populated in order to send to Azure. - :ivar database_type: The database type. Possible values include: "HANA", "DB2". + :ivar database_type: The database type. Known values are: "HANA" and "DB2". :vartype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :ivar subnet_id: Required. The subnet id. + :ivar subnet_id: The subnet id. Required. :vartype subnet_id: str - :ivar virtual_machine_configuration: Required. Gets or sets the virtual machine configuration. + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. :vartype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration - :ivar instance_count: Required. The number of database VMs. - :vartype instance_count: long + :ivar instance_count: The number of database VMs. Required. + :vartype instance_count: int """ _validation = { - 'subnet_id': {'required': True}, - 'virtual_machine_configuration': {'required': True}, - 'instance_count': {'required': True}, + "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': 'long'}, + "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"}, } def __init__( self, *, subnet_id: str, - virtual_machine_configuration: "VirtualMachineConfiguration", + virtual_machine_configuration: "_models.VirtualMachineConfiguration", instance_count: int, - database_type: Optional[Union[str, "SAPDatabaseType"]] = None, + database_type: Optional[Union[str, "_models.SAPDatabaseType"]] = None, **kwargs ): """ - :keyword database_type: The database type. Possible values include: "HANA", "DB2". + :keyword database_type: The database type. Known values are: "HANA" and "DB2". :paramtype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :keyword subnet_id: Required. The subnet id. + :keyword subnet_id: The subnet id. Required. :paramtype subnet_id: str - :keyword virtual_machine_configuration: Required. Gets or sets the virtual machine - configuration. + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. :paramtype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration - :keyword instance_count: Required. The number of database VMs. - :paramtype instance_count: long + :keyword instance_count: The number of database VMs. Required. + :paramtype instance_count: int """ - super(DatabaseConfiguration, self).__init__(**kwargs) + 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 -class DatabaseProfile(msrest.serialization.Model): +class DatabaseProfile(_serialization.Model): # pylint: disable=too-many-instance-attributes """Workload database profile. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Database type. Possible values include: "MySql". + :ivar type: Database type. Required. "MySql" :vartype type: str or ~azure.mgmt.workloads.models.DatabaseType :ivar server_name: Database server name. :vartype server_name: str :ivar version: Database version. :vartype version: str - :ivar sku: Required. The name of the server SKU, e.g. Standard_D32s_v4. + :ivar sku: The name of the server SKU, e.g. Standard_D32s_v4. Required. :vartype sku: str - :ivar tier: Required. Tier of the server SKU. Possible values include: "Burstable", - "GeneralPurpose", "MemoryOptimized". + :ivar tier: Tier of the server SKU. Required. Known values are: "Burstable", "GeneralPurpose", + and "MemoryOptimized". :vartype tier: str or ~azure.mgmt.workloads.models.DatabaseTier - :ivar ha_enabled: Whether to enable HA for the server. Possible values include: "Enabled", + :ivar ha_enabled: Whether to enable HA for the server. Known values are: "Enabled" and "Disabled". :vartype ha_enabled: str or ~azure.mgmt.workloads.models.HAEnabled :ivar storage_sku: SKU name for database storage. :vartype storage_sku: str :ivar storage_in_gb: Database storage size in GB. - :vartype storage_in_gb: long + :vartype storage_in_gb: int :ivar storage_iops: Storage IOPS for the server. - :vartype storage_iops: long + :vartype storage_iops: int :ivar backup_retention_days: Backup retention days for the server. :vartype backup_retention_days: int - :ivar ssl_enforcement_enabled: Whether to enable SSL enforcement on the database. Possible - values include: "Enabled", "Disabled". + :ivar ssl_enforcement_enabled: Whether to enable SSL enforcement on the database. Known values + are: "Enabled" and "Disabled". :vartype ssl_enforcement_enabled: str or ~azure.mgmt.workloads.models.EnableSslEnforcement :ivar server_resource_id: Azure Database Server resource Id. :vartype server_resource_id: str """ _validation = { - 'type': {'required': True}, - 'sku': {'required': True}, - 'tier': {'required': True}, - 'storage_in_gb': {'minimum': 1}, - 'server_resource_id': {'readonly': True}, + "type": {"required": True}, + "sku": {"required": True}, + "tier": {"required": True}, + "storage_in_gb": {"minimum": 1}, + "server_resource_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'server_name': {'key': 'serverName', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'ha_enabled': {'key': 'haEnabled', 'type': 'str'}, - 'storage_sku': {'key': 'storageSku', 'type': 'str'}, - 'storage_in_gb': {'key': 'storageInGB', 'type': 'long'}, - 'storage_iops': {'key': 'storageIops', 'type': 'long'}, - 'backup_retention_days': {'key': 'backupRetentionDays', 'type': 'int'}, - 'ssl_enforcement_enabled': {'key': 'sslEnforcementEnabled', 'type': 'str'}, - 'server_resource_id': {'key': 'serverResourceId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "server_name": {"key": "serverName", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "ha_enabled": {"key": "haEnabled", "type": "str"}, + "storage_sku": {"key": "storageSku", "type": "str"}, + "storage_in_gb": {"key": "storageInGB", "type": "int"}, + "storage_iops": {"key": "storageIops", "type": "int"}, + "backup_retention_days": {"key": "backupRetentionDays", "type": "int"}, + "ssl_enforcement_enabled": {"key": "sslEnforcementEnabled", "type": "str"}, + "server_resource_id": {"key": "serverResourceId", "type": "str"}, } def __init__( self, *, - type: Union[str, "DatabaseType"], + type: Union[str, "_models.DatabaseType"], sku: str, - tier: Union[str, "DatabaseTier"], + tier: Union[str, "_models.DatabaseTier"], server_name: Optional[str] = None, version: Optional[str] = None, - ha_enabled: Optional[Union[str, "HAEnabled"]] = None, + ha_enabled: Optional[Union[str, "_models.HAEnabled"]] = None, storage_sku: Optional[str] = None, storage_in_gb: Optional[int] = None, storage_iops: Optional[int] = None, backup_retention_days: Optional[int] = None, - ssl_enforcement_enabled: Optional[Union[str, "EnableSslEnforcement"]] = None, + ssl_enforcement_enabled: Optional[Union[str, "_models.EnableSslEnforcement"]] = None, **kwargs ): """ - :keyword type: Required. Database type. Possible values include: "MySql". + :keyword type: Database type. Required. "MySql" :paramtype type: str or ~azure.mgmt.workloads.models.DatabaseType :keyword server_name: Database server name. :paramtype server_name: str :keyword version: Database version. :paramtype version: str - :keyword sku: Required. The name of the server SKU, e.g. Standard_D32s_v4. + :keyword sku: The name of the server SKU, e.g. Standard_D32s_v4. Required. :paramtype sku: str - :keyword tier: Required. Tier of the server SKU. Possible values include: "Burstable", - "GeneralPurpose", "MemoryOptimized". + :keyword tier: Tier of the server SKU. Required. Known values are: "Burstable", + "GeneralPurpose", and "MemoryOptimized". :paramtype tier: str or ~azure.mgmt.workloads.models.DatabaseTier - :keyword ha_enabled: Whether to enable HA for the server. Possible values include: "Enabled", + :keyword ha_enabled: Whether to enable HA for the server. Known values are: "Enabled" and "Disabled". :paramtype ha_enabled: str or ~azure.mgmt.workloads.models.HAEnabled :keyword storage_sku: SKU name for database storage. :paramtype storage_sku: str :keyword storage_in_gb: Database storage size in GB. - :paramtype storage_in_gb: long + :paramtype storage_in_gb: int :keyword storage_iops: Storage IOPS for the server. - :paramtype storage_iops: long + :paramtype storage_iops: int :keyword backup_retention_days: Backup retention days for the server. :paramtype backup_retention_days: int - :keyword ssl_enforcement_enabled: Whether to enable SSL enforcement on the database. Possible - values include: "Enabled", "Disabled". + :keyword ssl_enforcement_enabled: Whether to enable SSL enforcement on the database. Known + values are: "Enabled" and "Disabled". :paramtype ssl_enforcement_enabled: str or ~azure.mgmt.workloads.models.EnableSslEnforcement """ - super(DatabaseProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.server_name = server_name self.version = version @@ -423,71 +423,71 @@ def __init__( self.server_resource_id = None -class DatabaseVmDetails(msrest.serialization.Model): - """The Database VM Details. +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. Possible values include: "Starting", "Running", - "Stopping", "Offline", "PartiallyRunning", "Unavailable". + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", and "Unavailable". :vartype status: str or ~azure.mgmt.workloads.models.SAPVirtualInstanceStatus """ _validation = { - 'virtual_machine_id': {'readonly': True}, - 'status': {'readonly': True}, + "virtual_machine_id": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'virtual_machine_id': {'key': 'virtualMachineId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DatabaseVmDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.virtual_machine_id = None self.status = None -class ProviderSpecificProperties(msrest.serialization.Model): +class ProviderSpecificProperties(_serialization.Model): """Gets or sets the provider specific properties. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DB2ProviderInstanceProperties, MsSqlServerProviderInstanceProperties, PrometheusHaClusterProviderInstanceProperties, PrometheusOSProviderInstanceProperties, HanaDbProviderInstanceProperties, SapNetWeaverProviderInstanceProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DB2ProviderInstanceProperties, MsSqlServerProviderInstanceProperties, + PrometheusHaClusterProviderInstanceProperties, PrometheusOSProviderInstanceProperties, + HanaDbProviderInstanceProperties, SapNetWeaverProviderInstanceProperties All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, } _subtype_map = { - 'provider_type': {'Db2': 'DB2ProviderInstanceProperties', 'MsSqlServer': 'MsSqlServerProviderInstanceProperties', 'PrometheusHaCluster': 'PrometheusHaClusterProviderInstanceProperties', 'PrometheusOS': 'PrometheusOSProviderInstanceProperties', 'SapHana': 'HanaDbProviderInstanceProperties', 'SapNetWeaver': 'SapNetWeaverProviderInstanceProperties'} - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(ProviderSpecificProperties, self).__init__(**kwargs) + "provider_type": { + "Db2": "DB2ProviderInstanceProperties", + "MsSqlServer": "MsSqlServerProviderInstanceProperties", + "PrometheusHaCluster": "PrometheusHaClusterProviderInstanceProperties", + "PrometheusOS": "PrometheusOSProviderInstanceProperties", + "SapHana": "HanaDbProviderInstanceProperties", + "SapNetWeaver": "SapNetWeaverProviderInstanceProperties", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider_type = None # type: Optional[str] @@ -496,8 +496,7 @@ class DB2ProviderInstanceProperties(ProviderSpecificProperties): All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str :ivar hostname: Gets or sets the target virtual machine name. :vartype hostname: str @@ -516,18 +515,18 @@ class DB2ProviderInstanceProperties(ProviderSpecificProperties): """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'hostname': {'key': 'hostname', 'type': 'str'}, - 'db_name': {'key': 'dbName', 'type': 'str'}, - 'db_port': {'key': 'dbPort', 'type': 'str'}, - 'db_username': {'key': 'dbUsername', 'type': 'str'}, - 'db_password': {'key': 'dbPassword', 'type': 'str'}, - 'db_password_uri': {'key': 'dbPasswordUri', 'type': 'str'}, - 'sap_sid': {'key': 'sapSid', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, + "hostname": {"key": "hostname", "type": "str"}, + "db_name": {"key": "dbName", "type": "str"}, + "db_port": {"key": "dbPort", "type": "str"}, + "db_username": {"key": "dbUsername", "type": "str"}, + "db_password": {"key": "dbPassword", "type": "str"}, + "db_password_uri": {"key": "dbPasswordUri", "type": "str"}, + "sap_sid": {"key": "sapSid", "type": "str"}, } def __init__( @@ -558,8 +557,8 @@ def __init__( :keyword sap_sid: Gets or sets the SAP System Identifier. :paramtype sap_sid: str """ - super(DB2ProviderInstanceProperties, self).__init__(**kwargs) - self.provider_type = 'Db2' # type: str + super().__init__(**kwargs) + self.provider_type = "Db2" # type: str self.hostname = hostname self.db_name = db_name self.db_port = db_port @@ -569,7 +568,7 @@ def __init__( self.sap_sid = sap_sid -class DeployerVmPackages(msrest.serialization.Model): +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. @@ -579,60 +578,54 @@ class DeployerVmPackages(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'storage_account_id': {'key': 'storageAccountId', 'type': 'str'}, + "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 - ): + def __init__(self, *, url: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs): """ :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(DeployerVmPackages, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.storage_account_id = storage_account_id -class SAPConfiguration(msrest.serialization.Model): +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. + 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 Azure. - :ivar configuration_type: Required. The configuration Type.Constant filled by server. Possible - values include: "Deployment", "Discovery", "DeploymentWithOSConfig". + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". :vartype configuration_type: str or ~azure.mgmt.workloads.models.SAPConfigurationType """ _validation = { - 'configuration_type': {'required': True}, + "configuration_type": {"required": True}, } _attribute_map = { - 'configuration_type': {'key': 'configurationType', 'type': 'str'}, + "configuration_type": {"key": "configurationType", "type": "str"}, } _subtype_map = { - 'configuration_type': {'Deployment': 'DeploymentConfiguration', 'DeploymentWithOSConfig': 'DeploymentWithOSConfiguration', 'Discovery': 'DiscoveryConfiguration'} + "configuration_type": { + "Deployment": "DeploymentConfiguration", + "DeploymentWithOSConfig": "DeploymentWithOSConfiguration", + "Discovery": "DiscoveryConfiguration", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(SAPConfiguration, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.configuration_type = None # type: Optional[str] @@ -641,8 +634,8 @@ class DeploymentConfiguration(SAPConfiguration): All required parameters must be populated in order to send to Azure. - :ivar configuration_type: Required. The configuration Type.Constant filled by server. Possible - values include: "Deployment", "Discovery", "DeploymentWithOSConfig". + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". :vartype configuration_type: str or ~azure.mgmt.workloads.models.SAPConfigurationType :ivar app_location: The geo-location where the SAP system is to be created. :vartype app_location: str @@ -653,22 +646,22 @@ class DeploymentConfiguration(SAPConfiguration): """ _validation = { - 'configuration_type': {'required': True}, + "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'}, + "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["InfrastructureConfiguration"] = None, - software_configuration: Optional["SoftwareConfiguration"] = None, + infrastructure_configuration: Optional["_models.InfrastructureConfiguration"] = None, + software_configuration: Optional["_models.SoftwareConfiguration"] = None, **kwargs ): """ @@ -680,8 +673,8 @@ def __init__( :keyword software_configuration: The software configuration. :paramtype software_configuration: ~azure.mgmt.workloads.models.SoftwareConfiguration """ - super(DeploymentConfiguration, self).__init__(**kwargs) - self.configuration_type = 'Deployment' # type: str + super().__init__(**kwargs) + self.configuration_type = "Deployment" # type: str self.app_location = app_location self.infrastructure_configuration = infrastructure_configuration self.software_configuration = software_configuration @@ -692,8 +685,8 @@ class DeploymentWithOSConfiguration(SAPConfiguration): All required parameters must be populated in order to send to Azure. - :ivar configuration_type: Required. The configuration Type.Constant filled by server. Possible - values include: "Deployment", "Discovery", "DeploymentWithOSConfig". + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". :vartype configuration_type: str or ~azure.mgmt.workloads.models.SAPConfigurationType :ivar app_location: The geo-location where the SAP system is to be created. :vartype app_location: str @@ -706,24 +699,24 @@ class DeploymentWithOSConfiguration(SAPConfiguration): """ _validation = { - 'configuration_type': {'required': True}, + "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'}, + "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["InfrastructureConfiguration"] = None, - software_configuration: Optional["SoftwareConfiguration"] = None, - os_sap_configuration: Optional["OsSapConfiguration"] = None, + infrastructure_configuration: Optional["_models.InfrastructureConfiguration"] = None, + software_configuration: Optional["_models.SoftwareConfiguration"] = None, + os_sap_configuration: Optional["_models.OsSapConfiguration"] = None, **kwargs ): """ @@ -737,8 +730,8 @@ def __init__( :keyword os_sap_configuration: The OS and SAP configuration. :paramtype os_sap_configuration: ~azure.mgmt.workloads.models.OsSapConfiguration """ - super(DeploymentWithOSConfiguration, self).__init__(**kwargs) - self.configuration_type = 'DeploymentWithOSConfig' # type: str + super().__init__(**kwargs) + self.configuration_type = "DeploymentWithOSConfig" # type: str self.app_location = app_location self.infrastructure_configuration = infrastructure_configuration self.software_configuration = software_configuration @@ -752,8 +745,8 @@ class DiscoveryConfiguration(SAPConfiguration): All required parameters must be populated in order to send to Azure. - :ivar configuration_type: Required. The configuration Type.Constant filled by server. Possible - values include: "Deployment", "Discovery", "DeploymentWithOSConfig". + :ivar configuration_type: The configuration Type. Required. Known values are: "Deployment", + "Discovery", and "DeploymentWithOSConfig". :vartype configuration_type: str or ~azure.mgmt.workloads.models.SAPConfigurationType :ivar central_server_vm_id: The virtual machine ID of the Central Server. :vartype central_server_vm_id: str @@ -762,122 +755,109 @@ class DiscoveryConfiguration(SAPConfiguration): """ _validation = { - 'configuration_type': {'required': True}, - 'app_location': {'readonly': True}, + "configuration_type": {"required": True}, + "app_location": {"readonly": True}, } _attribute_map = { - 'configuration_type': {'key': 'configurationType', 'type': 'str'}, - 'central_server_vm_id': {'key': 'centralServerVmId', 'type': 'str'}, - 'app_location': {'key': 'appLocation', 'type': 'str'}, + "configuration_type": {"key": "configurationType", "type": "str"}, + "central_server_vm_id": {"key": "centralServerVmId", "type": "str"}, + "app_location": {"key": "appLocation", "type": "str"}, } - def __init__( - self, - *, - central_server_vm_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, central_server_vm_id: Optional[str] = None, **kwargs): """ :keyword central_server_vm_id: The virtual machine ID of the Central Server. :paramtype central_server_vm_id: str """ - super(DiscoveryConfiguration, self).__init__(**kwargs) - self.configuration_type = 'Discovery' # type: str + super().__init__(**kwargs) + self.configuration_type = "Discovery" # type: str self.central_server_vm_id = central_server_vm_id self.app_location = None -class DiskInfo(msrest.serialization.Model): +class DiskInfo(_serialization.Model): """Disk resource creation details. All required parameters must be populated in order to send to Azure. - :ivar storage_type: Required. Storage type. Possible values include: "Premium_LRS", - "Standard_LRS", "StandardSSD_LRS". + :ivar storage_type: Storage type. Required. Known values are: "Premium_LRS", "Standard_LRS", + and "StandardSSD_LRS". :vartype storage_type: str or ~azure.mgmt.workloads.models.DiskStorageType :ivar size_in_gb: Disk size in GB. - :vartype size_in_gb: long + :vartype size_in_gb: int """ _validation = { - 'storage_type': {'required': True}, + "storage_type": {"required": True}, } _attribute_map = { - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'size_in_gb': {'key': 'sizeInGB', 'type': 'long'}, + "storage_type": {"key": "storageType", "type": "str"}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, } def __init__( - self, - *, - storage_type: Union[str, "DiskStorageType"], - size_in_gb: Optional[int] = None, - **kwargs + self, *, storage_type: Union[str, "_models.DiskStorageType"], size_in_gb: Optional[int] = None, **kwargs ): """ - :keyword storage_type: Required. Storage type. Possible values include: "Premium_LRS", - "Standard_LRS", "StandardSSD_LRS". + :keyword storage_type: Storage type. Required. Known values are: "Premium_LRS", "Standard_LRS", + and "StandardSSD_LRS". :paramtype storage_type: str or ~azure.mgmt.workloads.models.DiskStorageType :keyword size_in_gb: Disk size in GB. - :paramtype size_in_gb: long + :paramtype size_in_gb: int """ - super(DiskInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_type = storage_type self.size_in_gb = size_in_gb -class EnqueueReplicationServerProperties(msrest.serialization.Model): - """Defines the SAP ERS Server properties. +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. Possible values include: - "EnqueueReplicator1", "EnqueueReplicator2". + :ivar ers_version: Defines the type of Enqueue Replication Server. Known values are: + "EnqueueReplicator1" and "EnqueueReplicator2". :vartype ers_version: str or ~azure.mgmt.workloads.models.EnqueueReplicationServerType - :ivar instance_no: The ERS server instance id. + :ivar instance_no: ERS Instance Number. :vartype instance_no: str - :ivar hostname: The ERS server SAP host name. + :ivar hostname: ERS SAP Hostname. :vartype hostname: str - :ivar kernel_version: The ERS server SAP kernel version. + :ivar kernel_version: ERS SAP Kernel Version. :vartype kernel_version: str - :ivar kernel_patch: The ERS server SAP kernel patch. + :ivar kernel_patch: ERS SAP Kernel Patch level. :vartype kernel_patch: str - :ivar ip_address: The ERS server SAP IP Address. + :ivar ip_address: ERS SAP IP Address. :vartype ip_address: str - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". :vartype health: str or ~azure.mgmt.workloads.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}, + "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 - ): - """ - """ - super(EnqueueReplicationServerProperties, self).__init__(**kwargs) + "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): + """ """ + super().__init__(**kwargs) self.ers_version = None self.instance_no = None self.hostname = None @@ -887,50 +867,46 @@ def __init__( self.health = None -class EnqueueServerProperties(msrest.serialization.Model): - """Defines the SAP enqueue server properties. +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: The enqueue server SAP host name. + :ivar hostname: Enqueue Server SAP Hostname. :vartype hostname: str - :ivar ip_address: The enqueue server SAP IP Address. + :ivar ip_address: Enqueue Server SAP IP Address. :vartype ip_address: str - :ivar port: The enqueue server Port. - :vartype port: long - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :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.workloads.models.SAPHealthState """ _validation = { - 'hostname': {'readonly': True}, - 'ip_address': {'readonly': True}, - 'port': {'readonly': True}, - 'health': {'readonly': True}, + "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': 'long'}, - 'health': {'key': 'health', 'type': 'str'}, + "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 - ): - """ - """ - super(EnqueueServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.hostname = None self.ip_address = None self.port = None self.health = None -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """Standard error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -949,28 +925,24 @@ class Error(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'inner_error': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "inner_error": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'inner_error': {'key': 'innerError', 'type': 'ErrorInnerError'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[Error]"}, + "inner_error": {"key": "innerError", "type": "ErrorInnerError"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Error, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -978,7 +950,7 @@ def __init__( self.inner_error = None -class ErrorAdditionalInfo(msrest.serialization.Model): +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. @@ -986,31 +958,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -1024,30 +992,26 @@ class ErrorDefinition(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDefinition]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDefinition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.details = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -1065,28 +1029,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1094,7 +1054,7 @@ def __init__( self.additional_info = None -class ErrorInnerError(msrest.serialization.Model): +class ErrorInnerError(_serialization.Model): """Object containing more specific information than the current object about the error. :ivar inner_error: Standard error object. @@ -1102,24 +1062,19 @@ class ErrorInnerError(msrest.serialization.Model): """ _attribute_map = { - 'inner_error': {'key': 'innerError', 'type': 'Error'}, + "inner_error": {"key": "innerError", "type": "Error"}, } - def __init__( - self, - *, - inner_error: Optional["Error"] = None, - **kwargs - ): + def __init__(self, *, inner_error: Optional["_models.Error"] = None, **kwargs): """ :keyword inner_error: Standard error object. :paramtype inner_error: ~azure.mgmt.workloads.models.Error """ - super(ErrorInnerError, self).__init__(**kwargs) + super().__init__(**kwargs) self.inner_error = inner_error -class ErrorResponse(msrest.serialization.Model): +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. @@ -1127,38 +1082,103 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.workloads.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class FileshareProfile(msrest.serialization.Model): +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 Azure. + + :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.workloads.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): + """ """ + super().__init__(**kwargs) + self.software_installation_type = None # type: Optional[str] + + +class ExternalInstallationSoftwareConfiguration(SoftwareConfiguration): + """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 Azure. + + :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.workloads.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): + """ + :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 = "External" # type: str + self.central_server_vm_id = central_server_vm_id + + +class FileshareProfile(_serialization.Model): """File share profile. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar share_type: Required. Share type. Possible values include: "NfsOnController", - "AzureFiles". + :ivar share_type: Share type. Required. Known values are: "NfsOnController" and "AzureFiles". :vartype share_type: str or ~azure.mgmt.workloads.models.FileShareType - :ivar storage_type: Required. File share backing storage type. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS". + :ivar storage_type: File share backing storage type. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_ZRS", and "Premium_LRS". :vartype storage_type: str or ~azure.mgmt.workloads.models.FileShareStorageType :ivar share_size_in_gb: File share size in GB. - :vartype share_size_in_gb: long + :vartype share_size_in_gb: int :ivar storage_resource_id: File share storage resource id. :vartype storage_resource_id: str :ivar share_name: File share name. @@ -1166,40 +1186,40 @@ class FileshareProfile(msrest.serialization.Model): """ _validation = { - 'share_type': {'required': True}, - 'storage_type': {'required': True}, - 'share_size_in_gb': {'minimum': 1}, - 'storage_resource_id': {'readonly': True}, - 'share_name': {'readonly': True}, + "share_type": {"required": True}, + "storage_type": {"required": True}, + "share_size_in_gb": {"minimum": 1}, + "storage_resource_id": {"readonly": True}, + "share_name": {"readonly": True}, } _attribute_map = { - 'share_type': {'key': 'shareType', 'type': 'str'}, - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'share_size_in_gb': {'key': 'shareSizeInGB', 'type': 'long'}, - 'storage_resource_id': {'key': 'storageResourceId', 'type': 'str'}, - 'share_name': {'key': 'shareName', 'type': 'str'}, + "share_type": {"key": "shareType", "type": "str"}, + "storage_type": {"key": "storageType", "type": "str"}, + "share_size_in_gb": {"key": "shareSizeInGB", "type": "int"}, + "storage_resource_id": {"key": "storageResourceId", "type": "str"}, + "share_name": {"key": "shareName", "type": "str"}, } def __init__( self, *, - share_type: Union[str, "FileShareType"], - storage_type: Union[str, "FileShareStorageType"], + share_type: Union[str, "_models.FileShareType"], + storage_type: Union[str, "_models.FileShareStorageType"], share_size_in_gb: Optional[int] = None, **kwargs ): """ - :keyword share_type: Required. Share type. Possible values include: "NfsOnController", + :keyword share_type: Share type. Required. Known values are: "NfsOnController" and "AzureFiles". :paramtype share_type: str or ~azure.mgmt.workloads.models.FileShareType - :keyword storage_type: Required. File share backing storage type. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS". + :keyword storage_type: File share backing storage type. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_ZRS", and "Premium_LRS". :paramtype storage_type: str or ~azure.mgmt.workloads.models.FileShareStorageType :keyword share_size_in_gb: File share size in GB. - :paramtype share_size_in_gb: long + :paramtype share_size_in_gb: int """ - super(FileshareProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.share_type = share_type self.storage_type = storage_type self.share_size_in_gb = share_size_in_gb @@ -1207,35 +1227,31 @@ def __init__( self.share_name = None -class GatewayServerProperties(msrest.serialization.Model): +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: The gateway Port. - :vartype port: long - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :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.workloads.models.SAPHealthState """ _validation = { - 'port': {'readonly': True}, - 'health': {'readonly': True}, + "port": {"readonly": True}, + "health": {"readonly": True}, } _attribute_map = { - 'port': {'key': 'port', 'type': 'long'}, - 'health': {'key': 'health', 'type': 'str'}, + "port": {"key": "port", "type": "int"}, + "health": {"key": "health", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.port = None self.health = None @@ -1245,8 +1261,7 @@ class HanaDbProviderInstanceProperties(ProviderSpecificProperties): All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str :ivar hostname: Gets or sets the target virtual machine size. :vartype hostname: str @@ -1269,20 +1284,20 @@ class HanaDbProviderInstanceProperties(ProviderSpecificProperties): """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'hostname': {'key': 'hostname', 'type': 'str'}, - 'db_name': {'key': 'dbName', 'type': 'str'}, - 'sql_port': {'key': 'sqlPort', 'type': 'str'}, - 'instance_number': {'key': 'instanceNumber', 'type': 'str'}, - 'db_username': {'key': 'dbUsername', 'type': 'str'}, - 'db_password': {'key': 'dbPassword', 'type': 'str'}, - 'db_password_uri': {'key': 'dbPasswordUri', 'type': 'str'}, - 'db_ssl_certificate_uri': {'key': 'dbSslCertificateUri', 'type': 'str'}, - 'ssl_host_name_in_certificate': {'key': 'sslHostNameInCertificate', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, + "hostname": {"key": "hostname", "type": "str"}, + "db_name": {"key": "dbName", "type": "str"}, + "sql_port": {"key": "sqlPort", "type": "str"}, + "instance_number": {"key": "instanceNumber", "type": "str"}, + "db_username": {"key": "dbUsername", "type": "str"}, + "db_password": {"key": "dbPassword", "type": "str"}, + "db_password_uri": {"key": "dbPasswordUri", "type": "str"}, + "db_ssl_certificate_uri": {"key": "dbSslCertificateUri", "type": "str"}, + "ssl_host_name_in_certificate": {"key": "sslHostNameInCertificate", "type": "str"}, } def __init__( @@ -1319,8 +1334,8 @@ def __init__( :keyword ssl_host_name_in_certificate: Gets or sets the hostname(s) in the SSL certificate. :paramtype ssl_host_name_in_certificate: str """ - super(HanaDbProviderInstanceProperties, self).__init__(**kwargs) - self.provider_type = 'SapHana' # type: str + super().__init__(**kwargs) + self.provider_type = "SapHana" # type: str self.hostname = hostname self.db_name = db_name self.sql_port = sql_port @@ -1332,81 +1347,70 @@ def __init__( self.ssl_host_name_in_certificate = ssl_host_name_in_certificate -class HighAvailabilityConfiguration(msrest.serialization.Model): +class HighAvailabilityConfiguration(_serialization.Model): """Gets or sets the high availability configuration. All required parameters must be populated in order to send to Azure. - :ivar high_availability_type: Required. The high availability type. Possible values include: - "AvailabilitySet", "AvailabilityZone". + :ivar high_availability_type: The high availability type. Required. Known values are: + "AvailabilitySet" and "AvailabilityZone". :vartype high_availability_type: str or ~azure.mgmt.workloads.models.SAPHighAvailabilityType """ _validation = { - 'high_availability_type': {'required': True}, + "high_availability_type": {"required": True}, } _attribute_map = { - 'high_availability_type': {'key': 'highAvailabilityType', 'type': 'str'}, + "high_availability_type": {"key": "highAvailabilityType", "type": "str"}, } - def __init__( - self, - *, - high_availability_type: Union[str, "SAPHighAvailabilityType"], - **kwargs - ): + def __init__(self, *, high_availability_type: Union[str, "_models.SAPHighAvailabilityType"], **kwargs): """ - :keyword high_availability_type: Required. The high availability type. Possible values include: - "AvailabilitySet", "AvailabilityZone". + :keyword high_availability_type: The high availability type. Required. Known values are: + "AvailabilitySet" and "AvailabilityZone". :paramtype high_availability_type: str or ~azure.mgmt.workloads.models.SAPHighAvailabilityType """ - super(HighAvailabilityConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.high_availability_type = high_availability_type -class HighAvailabilitySoftwareConfiguration(msrest.serialization.Model): +class HighAvailabilitySoftwareConfiguration(_serialization.Model): """Gets or sets the HA software configuration. All required parameters must be populated in order to send to Azure. - :ivar fencing_client_id: Required. The fencing client id. + :ivar fencing_client_id: The fencing client id. Required. :vartype fencing_client_id: str - :ivar fencing_client_password: Required. The fencing client id secret/password. The secret - should never expire. This will be used pacemaker to start/stop the cluster VMs. + :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}, + "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'}, + "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 - ): + def __init__(self, *, fencing_client_id: str, fencing_client_password: str, **kwargs): """ - :keyword fencing_client_id: Required. The fencing client id. + :keyword fencing_client_id: The fencing client id. Required. :paramtype fencing_client_id: str - :keyword fencing_client_password: Required. The fencing client id secret/password. The secret - should never expire. This will be used pacemaker to start/stop the cluster VMs. + :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(HighAvailabilitySoftwareConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.fencing_client_id = fencing_client_id self.fencing_client_password = fencing_client_password -class ImageReference(msrest.serialization.Model): +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. Variables are only populated by the server, and will be ignored when sending a request. @@ -1434,16 +1438,16 @@ class ImageReference(msrest.serialization.Model): """ _validation = { - 'exact_version': {'readonly': True}, + "exact_version": {"readonly": True}, } _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'exact_version': {'key': 'exactVersion', 'type': 'str'}, - 'shared_gallery_image_id': {'key': 'sharedGalleryImageId', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "exact_version": {"key": "exactVersion", "type": "str"}, + "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, } def __init__( @@ -1474,7 +1478,7 @@ def __init__( deployment. This can be fetched from shared gallery image GET call. :paramtype shared_gallery_image_id: str """ - super(ImageReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.offer = offer self.sku = sku @@ -1483,84 +1487,72 @@ def __init__( self.shared_gallery_image_id = shared_gallery_image_id -class InfrastructureConfiguration(msrest.serialization.Model): +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. + 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 Azure. - :ivar deployment_type: Required. The deployment Type.Constant filled by server. Possible values - include: "SingleServer", "ThreeTier". + :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.workloads.models.SAPDeploymentType - :ivar app_resource_group: Required. The application resource group where SAP system resources - will be deployed. + :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}, + "deployment_type": {"required": True}, + "app_resource_group": {"required": True}, } _attribute_map = { - 'deployment_type': {'key': 'deploymentType', 'type': 'str'}, - 'app_resource_group': {'key': 'appResourceGroup', 'type': 'str'}, + "deployment_type": {"key": "deploymentType", "type": "str"}, + "app_resource_group": {"key": "appResourceGroup", "type": "str"}, } _subtype_map = { - 'deployment_type': {'SingleServer': 'SingleServerConfiguration', 'ThreeTier': 'ThreeTierConfiguration'} + "deployment_type": {"SingleServer": "SingleServerConfiguration", "ThreeTier": "ThreeTierConfiguration"} } - def __init__( - self, - *, - app_resource_group: str, - **kwargs - ): + def __init__(self, *, app_resource_group: str, **kwargs): """ - :keyword app_resource_group: Required. The application resource group where SAP system - resources will be deployed. + :keyword app_resource_group: The application resource group where SAP system resources will be + deployed. Required. :paramtype app_resource_group: str """ - super(InfrastructureConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.deployment_type = None # type: Optional[str] self.app_resource_group = app_resource_group -class OSConfiguration(msrest.serialization.Model): +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. + 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 Azure. - :ivar os_type: Required. The OS Type.Constant filled by server. Possible values include: - "Linux", "Windows". + :ivar os_type: The OS Type. Required. Known values are: "Linux" and "Windows". :vartype os_type: str or ~azure.mgmt.workloads.models.OSType """ _validation = { - 'os_type': {'required': True}, + "os_type": {"required": True}, } _attribute_map = { - 'os_type': {'key': 'osType', 'type': 'str'}, + "os_type": {"key": "osType", "type": "str"}, } - _subtype_map = { - 'os_type': {'Linux': 'LinuxConfiguration', 'Windows': 'WindowsConfiguration'} - } + _subtype_map = {"os_type": {"Linux": "LinuxConfiguration", "Windows": "WindowsConfiguration"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(OSConfiguration, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.os_type = None # type: Optional[str] @@ -1569,8 +1561,7 @@ class LinuxConfiguration(OSConfiguration): All required parameters must be populated in order to send to Azure. - :ivar os_type: Required. The OS Type.Constant filled by server. Possible values include: - "Linux", "Windows". + :ivar os_type: The OS Type. Required. Known values are: "Linux" and "Windows". :vartype os_type: str or ~azure.mgmt.workloads.models.OSType :ivar disable_password_authentication: Specifies whether password authentication should be disabled. @@ -1583,22 +1574,22 @@ class LinuxConfiguration(OSConfiguration): """ _validation = { - 'os_type': {'required': True}, + "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'}, + "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["SshConfiguration"] = None, - ssh_key_pair: Optional["SshKeyPair"] = None, + ssh: Optional["_models.SshConfiguration"] = None, + ssh_key_pair: Optional["_models.SshKeyPair"] = None, **kwargs ): """ @@ -1611,14 +1602,14 @@ def __init__( :keyword ssh_key_pair: The SSH Key-pair used to authenticate with the VM's. :paramtype ssh_key_pair: ~azure.mgmt.workloads.models.SshKeyPair """ - super(LinuxConfiguration, self).__init__(**kwargs) - self.os_type = 'Linux' # type: str + super().__init__(**kwargs) + self.os_type = "Linux" # type: str self.disable_password_authentication = disable_password_authentication self.ssh = ssh self.ssh_key_pair = ssh_key_pair -class ManagedRGConfiguration(msrest.serialization.Model): +class ManagedRGConfiguration(_serialization.Model): """Managed resource group configuration. :ivar name: Managed resource group name. @@ -1626,72 +1617,63 @@ class ManagedRGConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: Managed resource group name. :paramtype name: str """ - super(ManagedRGConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class MessageServerProperties(msrest.serialization.Model): - """Defines the SAP message server properties. +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: The message server port. - :vartype ms_port: long - :ivar internal_ms_port: The message server internal MS port. - :vartype internal_ms_port: long - :ivar http_port: The message server http port. - :vartype http_port: long - :ivar https_port: The message server https port. - :vartype https_port: long - :ivar hostname: The message server SAP host name. + :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: The message server IP Address. + :ivar ip_address: Message server IP Address. :vartype ip_address: str - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". :vartype health: str or ~azure.mgmt.workloads.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}, + "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': 'long'}, - 'internal_ms_port': {'key': 'internalMsPort', 'type': 'long'}, - 'http_port': {'key': 'httpPort', 'type': 'long'}, - 'https_port': {'key': 'httpsPort', 'type': 'long'}, - 'hostname': {'key': 'hostname', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'health': {'key': 'health', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageServerProperties, self).__init__(**kwargs) + "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): + """ """ + super().__init__(**kwargs) self.ms_port = None self.internal_ms_port = None self.http_port = None @@ -1701,7 +1683,7 @@ def __init__( self.health = None -class Resource(msrest.serialization.Model): +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. @@ -1720,26 +1702,22 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1764,48 +1742,42 @@ class TrackedResource(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :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}, + "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'}, + "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 - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class Monitor(TrackedResource): +class Monitor(TrackedResource): # pylint: disable=too-many-instance-attributes """SAP monitor info on Azure (ARM properties and SAP monitor properties). Variables are only populated by the server, and will be ignored when sending a request. @@ -1823,14 +1795,14 @@ class Monitor(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :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.workloads.models.UserAssignedServiceIdentity - :ivar provisioning_state: State of provisioning of the SAP monitor. Possible values include: - "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: State of provisioning of the SAP monitor. Known values are: + "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.WorkloadMonitorProvisioningState :ivar errors: Defines the SAP monitor errors. @@ -1839,8 +1811,11 @@ class Monitor(TrackedResource): The subnet region should be same as the SAP monitoring region. :vartype app_location: str :ivar routing_preference: Sets the routing preference of the SAP monitor. By default only - RFC1918 traffic is routed to the customer VNET. Possible values include: "Default", "RouteAll". + RFC1918 traffic is routed to the customer VNET. Known values are: "Default" and "RouteAll". :vartype routing_preference: str or ~azure.mgmt.workloads.models.RoutingPreference + :ivar zone_redundancy_preference: Sets the preference for zone redundancy on resources created + for the SAP monitor. By default resources will be created which do not support zone redundancy. + :vartype zone_redundancy_preference: str :ivar managed_resource_group_configuration: Managed resource group configuration. :vartype managed_resource_group_configuration: ~azure.mgmt.workloads.models.ManagedRGConfiguration @@ -1854,32 +1829,36 @@ class Monitor(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'errors': {'readonly': True}, - 'msi_arm_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedServiceIdentity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'errors': {'key': 'properties.errors', 'type': 'MonitorPropertiesErrors'}, - 'app_location': {'key': 'properties.appLocation', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'str'}, - 'managed_resource_group_configuration': {'key': 'properties.managedResourceGroupConfiguration', 'type': 'ManagedRGConfiguration'}, - 'log_analytics_workspace_arm_id': {'key': 'properties.logAnalyticsWorkspaceArmId', 'type': 'str'}, - 'monitor_subnet': {'key': 'properties.monitorSubnet', 'type': 'str'}, - 'msi_arm_id': {'key': 'properties.msiArmId', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, + "msi_arm_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "UserAssignedServiceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "errors": {"key": "properties.errors", "type": "MonitorPropertiesErrors"}, + "app_location": {"key": "properties.appLocation", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "str"}, + "zone_redundancy_preference": {"key": "properties.zoneRedundancyPreference", "type": "str"}, + "managed_resource_group_configuration": { + "key": "properties.managedResourceGroupConfiguration", + "type": "ManagedRGConfiguration", + }, + "log_analytics_workspace_arm_id": {"key": "properties.logAnalyticsWorkspaceArmId", "type": "str"}, + "monitor_subnet": {"key": "properties.monitorSubnet", "type": "str"}, + "msi_arm_id": {"key": "properties.msiArmId", "type": "str"}, } def __init__( @@ -1887,18 +1866,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["UserAssignedServiceIdentity"] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, app_location: Optional[str] = None, - routing_preference: Optional[Union[str, "RoutingPreference"]] = None, - managed_resource_group_configuration: Optional["ManagedRGConfiguration"] = None, + routing_preference: Optional[Union[str, "_models.RoutingPreference"]] = None, + zone_redundancy_preference: Optional[str] = None, + managed_resource_group_configuration: Optional["_models.ManagedRGConfiguration"] = None, log_analytics_workspace_arm_id: Optional[str] = None, monitor_subnet: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :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.workloads.models.UserAssignedServiceIdentity @@ -1906,8 +1886,12 @@ def __init__( The subnet region should be same as the SAP monitoring region. :paramtype app_location: str :keyword routing_preference: Sets the routing preference of the SAP monitor. By default only - RFC1918 traffic is routed to the customer VNET. Possible values include: "Default", "RouteAll". + RFC1918 traffic is routed to the customer VNET. Known values are: "Default" and "RouteAll". :paramtype routing_preference: str or ~azure.mgmt.workloads.models.RoutingPreference + :keyword zone_redundancy_preference: Sets the preference for zone redundancy on resources + created for the SAP monitor. By default resources will be created which do not support zone + redundancy. + :paramtype zone_redundancy_preference: str :keyword managed_resource_group_configuration: Managed resource group configuration. :paramtype managed_resource_group_configuration: ~azure.mgmt.workloads.models.ManagedRGConfiguration @@ -1917,19 +1901,20 @@ def __init__( :keyword monitor_subnet: The subnet which the SAP monitor will be deployed in. :paramtype monitor_subnet: str """ - super(Monitor, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.identity = identity self.provisioning_state = None self.errors = None self.app_location = app_location self.routing_preference = routing_preference + self.zone_redundancy_preference = zone_redundancy_preference self.managed_resource_group_configuration = managed_resource_group_configuration self.log_analytics_workspace_arm_id = log_analytics_workspace_arm_id self.monitor_subnet = monitor_subnet self.msi_arm_id = None -class MonitorListResult(msrest.serialization.Model): +class MonitorListResult(_serialization.Model): """The response from the List SAP monitors operation. :ivar value: The list of SAP monitors. @@ -1939,24 +1924,18 @@ class MonitorListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Monitor]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Monitor]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Monitor"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Monitor"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of SAP monitors. :paramtype value: list[~azure.mgmt.workloads.models.Monitor] :keyword next_link: The URL to get the next set of SAP monitors. :paramtype next_link: str """ - super(MonitorListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1980,28 +1959,24 @@ class MonitorPropertiesErrors(Error): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'inner_error': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "inner_error": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'inner_error': {'key': 'innerError', 'type': 'ErrorInnerError'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[Error]"}, + "inner_error": {"key": "innerError", "type": "ErrorInnerError"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MonitorPropertiesErrors, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class MsSqlServerProviderInstanceProperties(ProviderSpecificProperties): @@ -2009,8 +1984,7 @@ class MsSqlServerProviderInstanceProperties(ProviderSpecificProperties): All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str :ivar hostname: Gets or sets the SQL server host name. :vartype hostname: str @@ -2027,17 +2001,17 @@ class MsSqlServerProviderInstanceProperties(ProviderSpecificProperties): """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'hostname': {'key': 'hostname', 'type': 'str'}, - 'db_port': {'key': 'dbPort', 'type': 'str'}, - 'db_username': {'key': 'dbUsername', 'type': 'str'}, - 'db_password': {'key': 'dbPassword', 'type': 'str'}, - 'db_password_uri': {'key': 'dbPasswordUri', 'type': 'str'}, - 'sap_sid': {'key': 'sapSid', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, + "hostname": {"key": "hostname", "type": "str"}, + "db_port": {"key": "dbPort", "type": "str"}, + "db_username": {"key": "dbUsername", "type": "str"}, + "db_password": {"key": "dbPassword", "type": "str"}, + "db_password_uri": {"key": "dbPasswordUri", "type": "str"}, + "sap_sid": {"key": "sapSid", "type": "str"}, } def __init__( @@ -2065,8 +2039,8 @@ def __init__( :keyword sap_sid: Gets or sets the SAP System Identifier. :paramtype sap_sid: str """ - super(MsSqlServerProviderInstanceProperties, self).__init__(**kwargs) - self.provider_type = 'MsSqlServer' # type: str + super().__init__(**kwargs) + self.provider_type = "MsSqlServer" # type: str self.hostname = hostname self.db_port = db_port self.db_username = db_username @@ -2075,42 +2049,37 @@ def __init__( self.sap_sid = sap_sid -class NetworkConfiguration(msrest.serialization.Model): - """Defines the network configuration for SAP infrastructure. +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. + 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'}, + "is_secondary_ip_enabled": {"key": "isSecondaryIpEnabled", "type": "bool"}, } - def __init__( - self, - *, - is_secondary_ip_enabled: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, is_secondary_ip_enabled: bool = False, **kwargs): """ :keyword is_secondary_ip_enabled: Specifies whether a secondary IP address should be added to - the network interface on all VMs. + the network interface on all VMs of the SAP system being deployed. :paramtype is_secondary_ip_enabled: bool """ - super(NetworkConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_secondary_ip_enabled = is_secondary_ip_enabled -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """Network profile. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar load_balancer_type: Required. Load balancer type. Possible values include: - "ApplicationGateway", "LoadBalancer". + :ivar load_balancer_type: Load balancer type. Required. Known values are: "ApplicationGateway" + and "LoadBalancer". :vartype load_balancer_type: str or ~azure.mgmt.workloads.models.LoadBalancerType :ivar load_balancer_sku: Load balancer SKU. :vartype load_balancer_sku: str @@ -2118,8 +2087,8 @@ class NetworkProfile(msrest.serialization.Model): :vartype load_balancer_tier: str :ivar capacity: Capacity, applicable only for Application Gateway. :vartype capacity: int - :ivar azure_front_door_enabled: Whether to enable Azure front door. Possible values include: - "Enabled", "Disabled". + :ivar azure_front_door_enabled: Whether to enable Azure front door. Known values are: "Enabled" + and "Disabled". :vartype azure_front_door_enabled: str or ~azure.mgmt.workloads.models.AzureFrontDoorEnabled :ivar v_net_resource_id: Virtual network resource Id. :vartype v_net_resource_id: str @@ -2134,40 +2103,40 @@ class NetworkProfile(msrest.serialization.Model): """ _validation = { - 'load_balancer_type': {'required': True}, - 'v_net_resource_id': {'readonly': True}, - 'load_balancer_resource_id': {'readonly': True}, - 'azure_front_door_resource_id': {'readonly': True}, - 'front_end_public_ip_resource_id': {'readonly': True}, - 'outbound_public_ip_resource_ids': {'readonly': True}, + "load_balancer_type": {"required": True}, + "v_net_resource_id": {"readonly": True}, + "load_balancer_resource_id": {"readonly": True}, + "azure_front_door_resource_id": {"readonly": True}, + "front_end_public_ip_resource_id": {"readonly": True}, + "outbound_public_ip_resource_ids": {"readonly": True}, } _attribute_map = { - 'load_balancer_type': {'key': 'loadBalancerType', 'type': 'str'}, - 'load_balancer_sku': {'key': 'loadBalancerSku', 'type': 'str'}, - 'load_balancer_tier': {'key': 'loadBalancerTier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - 'azure_front_door_enabled': {'key': 'azureFrontDoorEnabled', 'type': 'str'}, - 'v_net_resource_id': {'key': 'vNetResourceId', 'type': 'str'}, - 'load_balancer_resource_id': {'key': 'loadBalancerResourceId', 'type': 'str'}, - 'azure_front_door_resource_id': {'key': 'azureFrontDoorResourceId', 'type': 'str'}, - 'front_end_public_ip_resource_id': {'key': 'frontEndPublicIpResourceId', 'type': 'str'}, - 'outbound_public_ip_resource_ids': {'key': 'outboundPublicIpResourceIds', 'type': '[str]'}, + "load_balancer_type": {"key": "loadBalancerType", "type": "str"}, + "load_balancer_sku": {"key": "loadBalancerSku", "type": "str"}, + "load_balancer_tier": {"key": "loadBalancerTier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + "azure_front_door_enabled": {"key": "azureFrontDoorEnabled", "type": "str"}, + "v_net_resource_id": {"key": "vNetResourceId", "type": "str"}, + "load_balancer_resource_id": {"key": "loadBalancerResourceId", "type": "str"}, + "azure_front_door_resource_id": {"key": "azureFrontDoorResourceId", "type": "str"}, + "front_end_public_ip_resource_id": {"key": "frontEndPublicIpResourceId", "type": "str"}, + "outbound_public_ip_resource_ids": {"key": "outboundPublicIpResourceIds", "type": "[str]"}, } def __init__( self, *, - load_balancer_type: Union[str, "LoadBalancerType"], + load_balancer_type: Union[str, "_models.LoadBalancerType"], load_balancer_sku: Optional[str] = None, load_balancer_tier: Optional[str] = None, capacity: Optional[int] = None, - azure_front_door_enabled: Optional[Union[str, "AzureFrontDoorEnabled"]] = None, + azure_front_door_enabled: Optional[Union[str, "_models.AzureFrontDoorEnabled"]] = None, **kwargs ): """ - :keyword load_balancer_type: Required. Load balancer type. Possible values include: - "ApplicationGateway", "LoadBalancer". + :keyword load_balancer_type: Load balancer type. Required. Known values are: + "ApplicationGateway" and "LoadBalancer". :paramtype load_balancer_type: str or ~azure.mgmt.workloads.models.LoadBalancerType :keyword load_balancer_sku: Load balancer SKU. :paramtype load_balancer_sku: str @@ -2175,11 +2144,11 @@ def __init__( :paramtype load_balancer_tier: str :keyword capacity: Capacity, applicable only for Application Gateway. :paramtype capacity: int - :keyword azure_front_door_enabled: Whether to enable Azure front door. Possible values include: - "Enabled", "Disabled". + :keyword azure_front_door_enabled: Whether to enable Azure front door. Known values are: + "Enabled" and "Disabled". :paramtype azure_front_door_enabled: str or ~azure.mgmt.workloads.models.AzureFrontDoorEnabled """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.load_balancer_type = load_balancer_type self.load_balancer_sku = load_balancer_sku self.load_balancer_tier = load_balancer_tier @@ -2192,7 +2161,7 @@ def __init__( self.outbound_public_ip_resource_ids = None -class NodeProfile(msrest.serialization.Model): +class NodeProfile(_serialization.Model): """VM or VMSS node profile. Variables are only populated by the server, and will be ignored when sending a request. @@ -2201,11 +2170,11 @@ class NodeProfile(msrest.serialization.Model): :ivar name: VM or VMSS name. :vartype name: str - :ivar node_sku: Required. VM SKU for node(s). + :ivar node_sku: VM SKU for node(s). Required. :vartype node_sku: str - :ivar os_image: Required. OS image used for creating the nodes. + :ivar os_image: OS image used for creating the nodes. Required. :vartype os_image: ~azure.mgmt.workloads.models.OsImageProfile - :ivar os_disk: Required. OS disk details. + :ivar os_disk: OS disk details. Required. :vartype os_disk: ~azure.mgmt.workloads.models.DiskInfo :ivar data_disks: Data disks details. This property is not in use right now. :vartype data_disks: list[~azure.mgmt.workloads.models.DiskInfo] @@ -2214,44 +2183,44 @@ class NodeProfile(msrest.serialization.Model): """ _validation = { - 'node_sku': {'required': True}, - 'os_image': {'required': True}, - 'os_disk': {'required': True}, - 'node_resource_ids': {'readonly': True}, + "node_sku": {"required": True}, + "os_image": {"required": True}, + "os_disk": {"required": True}, + "node_resource_ids": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'node_sku': {'key': 'nodeSku', 'type': 'str'}, - 'os_image': {'key': 'osImage', 'type': 'OsImageProfile'}, - 'os_disk': {'key': 'osDisk', 'type': 'DiskInfo'}, - 'data_disks': {'key': 'dataDisks', 'type': '[DiskInfo]'}, - 'node_resource_ids': {'key': 'nodeResourceIds', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "node_sku": {"key": "nodeSku", "type": "str"}, + "os_image": {"key": "osImage", "type": "OsImageProfile"}, + "os_disk": {"key": "osDisk", "type": "DiskInfo"}, + "data_disks": {"key": "dataDisks", "type": "[DiskInfo]"}, + "node_resource_ids": {"key": "nodeResourceIds", "type": "[str]"}, } def __init__( self, *, node_sku: str, - os_image: "OsImageProfile", - os_disk: "DiskInfo", + os_image: "_models.OsImageProfile", + os_disk: "_models.DiskInfo", name: Optional[str] = None, - data_disks: Optional[List["DiskInfo"]] = None, + data_disks: Optional[List["_models.DiskInfo"]] = None, **kwargs ): """ :keyword name: VM or VMSS name. :paramtype name: str - :keyword node_sku: Required. VM SKU for node(s). + :keyword node_sku: VM SKU for node(s). Required. :paramtype node_sku: str - :keyword os_image: Required. OS image used for creating the nodes. + :keyword os_image: OS image used for creating the nodes. Required. :paramtype os_image: ~azure.mgmt.workloads.models.OsImageProfile - :keyword os_disk: Required. OS disk details. + :keyword os_disk: OS disk details. Required. :paramtype os_disk: ~azure.mgmt.workloads.models.DiskInfo :keyword data_disks: Data disks details. This property is not in use right now. :paramtype data_disks: list[~azure.mgmt.workloads.models.DiskInfo] """ - super(NodeProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.node_sku = node_sku self.os_image = os_image @@ -2260,7 +2229,7 @@ def __init__( self.node_resource_ids = None -class Operation(msrest.serialization.Model): +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. @@ -2274,40 +2243,35 @@ class Operation(msrest.serialization.Model): :ivar display: Localized display information for this particular operation. :vartype display: ~azure.mgmt.workloads.models.OperationDisplay :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", - "system", "user,system". + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". :vartype origin: str or ~azure.mgmt.workloads.models.Origin :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. "Internal" :vartype action_type: str or ~azure.mgmt.workloads.models.ActionType """ _validation = { - 'name': {'readonly': True}, - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, - 'action_type': {'readonly': True}, + "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'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: Localized display information for this particular operation. :paramtype display: ~azure.mgmt.workloads.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_data_action = None self.display = display @@ -2315,7 +2279,7 @@ def __init__( self.action_type = None -class OperationDisplay(msrest.serialization.Model): +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. @@ -2335,33 +2299,29 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "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'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationListResult(msrest.serialization.Model): +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. @@ -2373,22 +2333,18 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -2413,36 +2369,36 @@ class OperationsContent(Resource): :vartype name_properties_name: str :ivar is_data_action: Indicates whether the operation applies to data-plane. :vartype is_data_action: bool - :ivar origin: Defines the workload operation origin. Possible values include: "NotSpecified", - "User", "System". + :ivar origin: Defines the workload operation origin. Known values are: "NotSpecified", "User", + and "System". :vartype origin: str or ~azure.mgmt.workloads.models.OperationProperties :ivar display: Display information of the operation. :vartype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay - :ivar action_type: Defines the action type of workload operation. Possible values include: - "NotSpecified", "Internal". + :ivar action_type: Defines the action type of workload operation. Known values are: + "NotSpecified" and "Internal". :vartype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType :ivar properties: Defines the workload operation properties. :vartype properties: any """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'is_data_action': {'key': 'properties.isDataAction', 'type': 'bool'}, - 'origin': {'key': 'properties.origin', 'type': 'str'}, - 'display': {'key': 'properties.display', 'type': 'OperationsDefinitionDisplay'}, - 'action_type': {'key': 'properties.actionType', 'type': 'str'}, - 'properties': {'key': 'properties.properties', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "is_data_action": {"key": "properties.isDataAction", "type": "bool"}, + "origin": {"key": "properties.origin", "type": "str"}, + "display": {"key": "properties.display", "type": "OperationsDefinitionDisplay"}, + "action_type": {"key": "properties.actionType", "type": "str"}, + "properties": {"key": "properties.properties", "type": "object"}, } def __init__( @@ -2450,9 +2406,9 @@ def __init__( *, name_properties_name: Optional[str] = None, is_data_action: Optional[bool] = None, - origin: Optional[Union[str, "OperationProperties"]] = None, - display: Optional["OperationsDefinitionDisplay"] = None, - action_type: Optional[Union[str, "WorkloadMonitorActionType"]] = None, + origin: Optional[Union[str, "_models.OperationProperties"]] = None, + display: Optional["_models.OperationsDefinitionDisplay"] = None, + action_type: Optional[Union[str, "_models.WorkloadMonitorActionType"]] = None, properties: Optional[Any] = None, **kwargs ): @@ -2461,18 +2417,18 @@ def __init__( :paramtype name_properties_name: str :keyword is_data_action: Indicates whether the operation applies to data-plane. :paramtype is_data_action: bool - :keyword origin: Defines the workload operation origin. Possible values include: - "NotSpecified", "User", "System". + :keyword origin: Defines the workload operation origin. Known values are: "NotSpecified", + "User", and "System". :paramtype origin: str or ~azure.mgmt.workloads.models.OperationProperties :keyword display: Display information of the operation. :paramtype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay - :keyword action_type: Defines the action type of workload operation. Possible values include: - "NotSpecified", "Internal". + :keyword action_type: Defines the action type of workload operation. Known values are: + "NotSpecified" and "Internal". :paramtype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType :keyword properties: Defines the workload operation properties. :paramtype properties: any """ - super(OperationsContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_properties_name = name_properties_name self.is_data_action = is_data_action self.origin = origin @@ -2481,69 +2437,69 @@ def __init__( self.properties = properties -class OperationsDefinition(msrest.serialization.Model): +class OperationsDefinition(_serialization.Model): """Properties of an Operation. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the operation. + :ivar name: Name of the operation. Required. :vartype name: str :ivar is_data_action: Indicates whether the operation applies to data-plane. :vartype is_data_action: bool - :ivar origin: Defines the workload operation origin. Possible values include: "NotSpecified", - "User", "System". + :ivar origin: Defines the workload operation origin. Known values are: "NotSpecified", "User", + and "System". :vartype origin: str or ~azure.mgmt.workloads.models.OperationProperties - :ivar display: Required. Display information of the operation. + :ivar display: Display information of the operation. Required. :vartype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay - :ivar action_type: Defines the action type of workload operation. Possible values include: - "NotSpecified", "Internal". + :ivar action_type: Defines the action type of workload operation. Known values are: + "NotSpecified" and "Internal". :vartype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType :ivar properties: Defines the workload operation properties. :vartype properties: any """ _validation = { - 'name': {'required': True}, - 'display': {'required': True}, + "name": {"required": True}, + "display": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationsDefinitionDisplay'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, + "display": {"key": "display", "type": "OperationsDefinitionDisplay"}, + "action_type": {"key": "actionType", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( self, *, name: str, - display: "OperationsDefinitionDisplay", + display: "_models.OperationsDefinitionDisplay", is_data_action: Optional[bool] = None, - origin: Optional[Union[str, "OperationProperties"]] = None, - action_type: Optional[Union[str, "WorkloadMonitorActionType"]] = None, + origin: Optional[Union[str, "_models.OperationProperties"]] = None, + action_type: Optional[Union[str, "_models.WorkloadMonitorActionType"]] = None, properties: Optional[Any] = None, **kwargs ): """ - :keyword name: Required. Name of the operation. + :keyword name: Name of the operation. Required. :paramtype name: str :keyword is_data_action: Indicates whether the operation applies to data-plane. :paramtype is_data_action: bool - :keyword origin: Defines the workload operation origin. Possible values include: - "NotSpecified", "User", "System". + :keyword origin: Defines the workload operation origin. Known values are: "NotSpecified", + "User", and "System". :paramtype origin: str or ~azure.mgmt.workloads.models.OperationProperties - :keyword display: Required. Display information of the operation. + :keyword display: Display information of the operation. Required. :paramtype display: ~azure.mgmt.workloads.models.OperationsDefinitionDisplay - :keyword action_type: Defines the action type of workload operation. Possible values include: - "NotSpecified", "Internal". + :keyword action_type: Defines the action type of workload operation. Known values are: + "NotSpecified" and "Internal". :paramtype action_type: str or ~azure.mgmt.workloads.models.WorkloadMonitorActionType :keyword properties: Defines the workload operation properties. :paramtype properties: any """ - super(OperationsDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.origin = origin @@ -2552,7 +2508,7 @@ def __init__( self.properties = properties -class OperationsDefinitionArrayResponseWithContinuation(msrest.serialization.Model): +class OperationsDefinitionArrayResponseWithContinuation(_serialization.Model): """Defines the workload operation definition response. :ivar value: Defines the workload operation definition response properties. @@ -2562,16 +2518,12 @@ class OperationsDefinitionArrayResponseWithContinuation(msrest.serialization.Mod """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationsDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationsDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationsDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationsDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Defines the workload operation definition response properties. @@ -2579,60 +2531,52 @@ def __init__( :keyword next_link: The URL to get to the next set of results, if there are any. :paramtype next_link: str """ - super(OperationsDefinitionArrayResponseWithContinuation, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationsDisplayDefinition(msrest.serialization.Model): +class OperationsDisplayDefinition(_serialization.Model): """Defines the workload operation. All required parameters must be populated in order to send to Azure. - :ivar provider: Required. Defines the workload provider. + :ivar provider: Defines the workload provider. Required. :vartype provider: str - :ivar resource: Required. Defines the workload resource. + :ivar resource: Defines the workload resource. Required. :vartype resource: str - :ivar operation: Required. Defines the workload operation. + :ivar operation: Defines the workload operation. Required. :vartype operation: str - :ivar description: Required. Describes the workload operation. + :ivar description: Describes the workload operation. Required. :vartype description: str """ _validation = { - 'provider': {'required': True}, - 'resource': {'required': True}, - 'operation': {'required': True}, - 'description': {'required': True}, + "provider": {"required": True}, + "resource": {"required": True}, + "operation": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - *, - provider: str, - resource: str, - operation: str, - description: str, - **kwargs - ): + def __init__(self, *, provider: str, resource: str, operation: str, description: str, **kwargs): """ - :keyword provider: Required. Defines the workload provider. + :keyword provider: Defines the workload provider. Required. :paramtype provider: str - :keyword resource: Required. Defines the workload resource. + :keyword resource: Defines the workload resource. Required. :paramtype resource: str - :keyword operation: Required. Defines the workload operation. + :keyword operation: Defines the workload operation. Required. :paramtype operation: str - :keyword description: Required. Describes the workload operation. + :keyword description: Describes the workload operation. Required. :paramtype description: str """ - super(OperationsDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation @@ -2644,53 +2588,45 @@ class OperationsDefinitionDisplay(OperationsDisplayDefinition): All required parameters must be populated in order to send to Azure. - :ivar provider: Required. Defines the workload provider. + :ivar provider: Defines the workload provider. Required. :vartype provider: str - :ivar resource: Required. Defines the workload resource. + :ivar resource: Defines the workload resource. Required. :vartype resource: str - :ivar operation: Required. Defines the workload operation. + :ivar operation: Defines the workload operation. Required. :vartype operation: str - :ivar description: Required. Describes the workload operation. + :ivar description: Describes the workload operation. Required. :vartype description: str """ _validation = { - 'provider': {'required': True}, - 'resource': {'required': True}, - 'operation': {'required': True}, - 'description': {'required': True}, + "provider": {"required": True}, + "resource": {"required": True}, + "operation": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - *, - provider: str, - resource: str, - operation: str, - description: str, - **kwargs - ): + def __init__(self, *, provider: str, resource: str, operation: str, description: str, **kwargs): """ - :keyword provider: Required. Defines the workload provider. + :keyword provider: Defines the workload provider. Required. :paramtype provider: str - :keyword resource: Required. Defines the workload resource. + :keyword resource: Defines the workload resource. Required. :paramtype resource: str - :keyword operation: Required. Defines the workload operation. + :keyword operation: Defines the workload operation. Required. :paramtype operation: str - :keyword description: Required. Describes the workload operation. + :keyword description: Describes the workload operation. Required. :paramtype description: str """ - super(OperationsDefinitionDisplay, self).__init__(provider=provider, resource=resource, operation=operation, description=description, **kwargs) + super().__init__(provider=provider, resource=resource, operation=operation, description=description, **kwargs) -class OperationStatusResult(msrest.serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. All required parameters must be populated in order to send to Azure. @@ -2699,7 +2635,7 @@ class OperationStatusResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the async operation. :vartype name: str - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar percent_complete: Percent of the operation that is complete. :vartype percent_complete: float @@ -2714,32 +2650,32 @@ class OperationStatusResult(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'percent_complete': {'maximum': 100, 'minimum': 0}, + "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'}, + "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, + 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["OperationStatusResult"]] = None, - error: Optional["ErrorDetail"] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -2747,7 +2683,7 @@ def __init__( :paramtype id: str :keyword name: Name of the async operation. :paramtype name: str - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword percent_complete: Percent of the operation that is complete. :paramtype percent_complete: float @@ -2760,7 +2696,7 @@ def __init__( :keyword error: If present, details of the operation error. :paramtype error: ~azure.mgmt.workloads.models.ErrorDetail """ - super(OperationStatusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -2771,53 +2707,53 @@ def __init__( self.error = error -class OsImageProfile(msrest.serialization.Model): +class OsImageProfile(_serialization.Model): """OS image profile. - :ivar publisher: OS image publisher. Possible values include: "Canonical". + :ivar publisher: OS image publisher. "Canonical" :vartype publisher: str or ~azure.mgmt.workloads.models.OSImagePublisher - :ivar offer: OS image offer. Possible values include: "UbuntuServer". + :ivar offer: OS image offer. "UbuntuServer" :vartype offer: str or ~azure.mgmt.workloads.models.OSImageOffer - :ivar sku: OS image sku. Possible values include: "18.04-LTS", "16.04-LTS". + :ivar sku: OS image sku. Known values are: "18.04-LTS" and "16.04-LTS". :vartype sku: str or ~azure.mgmt.workloads.models.OSImageSku - :ivar version: OS image version. Possible values include: "latest". + :ivar version: OS image version. "latest" :vartype version: str or ~azure.mgmt.workloads.models.OSImageVersion """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - publisher: Optional[Union[str, "OSImagePublisher"]] = None, - offer: Optional[Union[str, "OSImageOffer"]] = None, - sku: Optional[Union[str, "OSImageSku"]] = None, - version: Optional[Union[str, "OSImageVersion"]] = None, + publisher: Optional[Union[str, "_models.OSImagePublisher"]] = None, + offer: Optional[Union[str, "_models.OSImageOffer"]] = None, + sku: Optional[Union[str, "_models.OSImageSku"]] = None, + version: Optional[Union[str, "_models.OSImageVersion"]] = None, **kwargs ): """ - :keyword publisher: OS image publisher. Possible values include: "Canonical". + :keyword publisher: OS image publisher. "Canonical" :paramtype publisher: str or ~azure.mgmt.workloads.models.OSImagePublisher - :keyword offer: OS image offer. Possible values include: "UbuntuServer". + :keyword offer: OS image offer. "UbuntuServer" :paramtype offer: str or ~azure.mgmt.workloads.models.OSImageOffer - :keyword sku: OS image sku. Possible values include: "18.04-LTS", "16.04-LTS". + :keyword sku: OS image sku. Known values are: "18.04-LTS" and "16.04-LTS". :paramtype sku: str or ~azure.mgmt.workloads.models.OSImageSku - :keyword version: OS image version. Possible values include: "latest". + :keyword version: OS image version. "latest" :paramtype version: str or ~azure.mgmt.workloads.models.OSImageVersion """ - super(OsImageProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.offer = offer self.sku = sku self.version = version -class OSProfile(msrest.serialization.Model): +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:`
` @@ -2850,9 +2786,9 @@ class OSProfile(msrest.serialization.Model): """ _attribute_map = { - 'admin_username': {'key': 'adminUsername', 'type': 'str'}, - 'admin_password': {'key': 'adminPassword', 'type': 'str'}, - 'os_configuration': {'key': 'osConfiguration', 'type': 'OSConfiguration'}, + "admin_username": {"key": "adminUsername", "type": "str"}, + "admin_password": {"key": "adminPassword", "type": "str"}, + "os_configuration": {"key": "osConfiguration", "type": "OSConfiguration"}, } def __init__( @@ -2860,7 +2796,7 @@ def __init__( *, admin_username: Optional[str] = None, admin_password: Optional[str] = None, - os_configuration: Optional["OSConfiguration"] = None, + os_configuration: Optional["_models.OSConfiguration"] = None, **kwargs ): """ @@ -2893,13 +2829,13 @@ def __init__( :keyword os_configuration: Specifies Windows operating system settings on the virtual machine. :paramtype os_configuration: ~azure.mgmt.workloads.models.OSConfiguration """ - super(OSProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.admin_username = admin_username self.admin_password = admin_password self.os_configuration = os_configuration -class OsSapConfiguration(msrest.serialization.Model): +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 @@ -2910,14 +2846,14 @@ class OsSapConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'deployer_vm_packages': {'key': 'deployerVmPackages', 'type': 'DeployerVmPackages'}, - 'sap_fqdn': {'key': 'sapFqdn', 'type': 'str'}, + "deployer_vm_packages": {"key": "deployerVmPackages", "type": "DeployerVmPackages"}, + "sap_fqdn": {"key": "sapFqdn", "type": "str"}, } def __init__( self, *, - deployer_vm_packages: Optional["DeployerVmPackages"] = None, + deployer_vm_packages: Optional["_models.DeployerVmPackages"] = None, sap_fqdn: Optional[str] = None, **kwargs ): @@ -2928,79 +2864,78 @@ def __init__( :keyword sap_fqdn: The FQDN to set for the SAP system. :paramtype sap_fqdn: str """ - super(OsSapConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.deployer_vm_packages = deployer_vm_packages self.sap_fqdn = sap_fqdn -class PatchResourceRequestBody(msrest.serialization.Model): +class PatchResourceRequestBody(_serialization.Model): """Resource patch request body. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar identity: :vartype identity: ~azure.mgmt.workloads.models.PatchResourceRequestBodyIdentity """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'PatchResourceRequestBodyIdentity'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "PatchResourceRequestBodyIdentity"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["PatchResourceRequestBodyIdentity"] = None, + identity: Optional["_models.PatchResourceRequestBodyIdentity"] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword identity: :paramtype identity: ~azure.mgmt.workloads.models.PatchResourceRequestBodyIdentity """ - super(PatchResourceRequestBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity -class UserAssignedServiceIdentity(msrest.serialization.Model): +class UserAssignedServiceIdentity(_serialization.Model): """Managed service identity (user assigned identities). All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of manage identity. Possible values include: "None", "UserAssigned". + :ivar type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". :vartype type: str or ~azure.mgmt.workloads.models.ManagedServiceIdentityType :ivar user_assigned_identities: User assigned identities dictionary. :vartype user_assigned_identities: dict[str, ~azure.mgmt.workloads.models.UserAssignedIdentity] """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Union[str, "ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. Type of manage identity. Possible values include: "None", - "UserAssigned". + :keyword type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". :paramtype type: str or ~azure.mgmt.workloads.models.ManagedServiceIdentityType :keyword user_assigned_identities: User assigned identities dictionary. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.workloads.models.UserAssignedIdentity] """ - super(UserAssignedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.user_assigned_identities = user_assigned_identities @@ -3010,71 +2945,65 @@ class PatchResourceRequestBodyIdentity(UserAssignedServiceIdentity): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of manage identity. Possible values include: "None", "UserAssigned". + :ivar type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". :vartype type: str or ~azure.mgmt.workloads.models.ManagedServiceIdentityType :ivar user_assigned_identities: User assigned identities dictionary. :vartype user_assigned_identities: dict[str, ~azure.mgmt.workloads.models.UserAssignedIdentity] """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Union[str, "ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. Type of manage identity. Possible values include: "None", - "UserAssigned". + :keyword type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". :paramtype type: str or ~azure.mgmt.workloads.models.ManagedServiceIdentityType :keyword user_assigned_identities: User assigned identities dictionary. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.workloads.models.UserAssignedIdentity] """ - super(PatchResourceRequestBodyIdentity, self).__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) + super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) -class PhpProfile(msrest.serialization.Model): +class PhpProfile(_serialization.Model): """PHP profile. All required parameters must be populated in order to send to Azure. - :ivar version: Required. PHP version. Possible values include: "7.2", "7.3", "7.4". + :ivar version: PHP version. Required. Known values are: "7.2", "7.3", and "7.4". :vartype version: str or ~azure.mgmt.workloads.models.PHPVersion """ _validation = { - 'version': {'required': True}, + "version": {"required": True}, } _attribute_map = { - 'version': {'key': 'version', 'type': 'str'}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - version: Union[str, "PHPVersion"], - **kwargs - ): + def __init__(self, *, version: Union[str, "_models.PHPVersion"], **kwargs): """ - :keyword version: Required. PHP version. Possible values include: "7.2", "7.3", "7.4". + :keyword version: PHP version. Required. Known values are: "7.2", "7.3", and "7.4". :paramtype version: str or ~azure.mgmt.workloads.models.PHPVersion """ - super(PhpProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = version -class PhpWorkloadResource(TrackedResource): +class PhpWorkloadResource(TrackedResource): # pylint: disable=too-many-instance-attributes """Php workload resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3092,12 +3021,12 @@ class PhpWorkloadResource(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar kind: Required. Indicates which kind of php workload this resource represent e.g - WordPress. Possible values include: "WordPress". + :ivar kind: Indicates which kind of php workload this resource represent e.g WordPress. + Required. "WordPress" :vartype kind: str or ~azure.mgmt.workloads.models.WorkloadKind :ivar sku: Php workloads SKU. :vartype sku: ~azure.mgmt.workloads.models.Sku @@ -3131,78 +3060,81 @@ class PhpWorkloadResource(TrackedResource): :vartype cache_profile: ~azure.mgmt.workloads.models.CacheProfile :ivar backup_profile: Backup profile. :vartype backup_profile: ~azure.mgmt.workloads.models.BackupProfile - :ivar provisioning_state: Php workload resource provisioning state. Possible values include: - "NotSpecified", "Accepted", "Created", "Succeeded", "Failed", "Canceled", "Provisioning", + :ivar provisioning_state: Php workload resource provisioning state. Known values are: + "NotSpecified", "Accepted", "Created", "Succeeded", "Failed", "Canceled", "Provisioning", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.PhpWorkloadProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'PhpWorkloadResourceIdentity'}, - 'app_location': {'key': 'properties.appLocation', 'type': 'str'}, - 'managed_resource_group_configuration': {'key': 'properties.managedResourceGroupConfiguration', 'type': 'ManagedRGConfiguration'}, - 'admin_user_profile': {'key': 'properties.adminUserProfile', 'type': 'UserProfile'}, - 'web_nodes_profile': {'key': 'properties.webNodesProfile', 'type': 'VmssNodesProfile'}, - 'controller_profile': {'key': 'properties.controllerProfile', 'type': 'NodeProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'database_profile': {'key': 'properties.databaseProfile', 'type': 'DatabaseProfile'}, - 'site_profile': {'key': 'properties.siteProfile', 'type': 'SiteProfile'}, - 'fileshare_profile': {'key': 'properties.fileshareProfile', 'type': 'FileshareProfile'}, - 'php_profile': {'key': 'properties.phpProfile', 'type': 'PhpProfile'}, - 'search_profile': {'key': 'properties.searchProfile', 'type': 'SearchProfile'}, - 'cache_profile': {'key': 'properties.cacheProfile', 'type': 'CacheProfile'}, - 'backup_profile': {'key': 'properties.backupProfile', 'type': 'BackupProfile'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "kind": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "PhpWorkloadResourceIdentity"}, + "app_location": {"key": "properties.appLocation", "type": "str"}, + "managed_resource_group_configuration": { + "key": "properties.managedResourceGroupConfiguration", + "type": "ManagedRGConfiguration", + }, + "admin_user_profile": {"key": "properties.adminUserProfile", "type": "UserProfile"}, + "web_nodes_profile": {"key": "properties.webNodesProfile", "type": "VmssNodesProfile"}, + "controller_profile": {"key": "properties.controllerProfile", "type": "NodeProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "database_profile": {"key": "properties.databaseProfile", "type": "DatabaseProfile"}, + "site_profile": {"key": "properties.siteProfile", "type": "SiteProfile"}, + "fileshare_profile": {"key": "properties.fileshareProfile", "type": "FileshareProfile"}, + "php_profile": {"key": "properties.phpProfile", "type": "PhpProfile"}, + "search_profile": {"key": "properties.searchProfile", "type": "SearchProfile"}, + "cache_profile": {"key": "properties.cacheProfile", "type": "CacheProfile"}, + "backup_profile": {"key": "properties.backupProfile", "type": "BackupProfile"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: str, - kind: Union[str, "WorkloadKind"], + kind: Union[str, "_models.WorkloadKind"], tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - identity: Optional["PhpWorkloadResourceIdentity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.PhpWorkloadResourceIdentity"] = None, app_location: Optional[str] = None, - managed_resource_group_configuration: Optional["ManagedRGConfiguration"] = None, - admin_user_profile: Optional["UserProfile"] = None, - web_nodes_profile: Optional["VmssNodesProfile"] = None, - controller_profile: Optional["NodeProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - database_profile: Optional["DatabaseProfile"] = None, - site_profile: Optional["SiteProfile"] = None, - fileshare_profile: Optional["FileshareProfile"] = None, - php_profile: Optional["PhpProfile"] = None, - search_profile: Optional["SearchProfile"] = None, - cache_profile: Optional["CacheProfile"] = None, - backup_profile: Optional["BackupProfile"] = None, + managed_resource_group_configuration: Optional["_models.ManagedRGConfiguration"] = None, + admin_user_profile: Optional["_models.UserProfile"] = None, + web_nodes_profile: Optional["_models.VmssNodesProfile"] = None, + controller_profile: Optional["_models.NodeProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + database_profile: Optional["_models.DatabaseProfile"] = None, + site_profile: Optional["_models.SiteProfile"] = None, + fileshare_profile: Optional["_models.FileshareProfile"] = None, + php_profile: Optional["_models.PhpProfile"] = None, + search_profile: Optional["_models.SearchProfile"] = None, + cache_profile: Optional["_models.CacheProfile"] = None, + backup_profile: Optional["_models.BackupProfile"] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword kind: Required. Indicates which kind of php workload this resource represent e.g - WordPress. Possible values include: "WordPress". + :keyword kind: Indicates which kind of php workload this resource represent e.g WordPress. + Required. "WordPress" :paramtype kind: str or ~azure.mgmt.workloads.models.WorkloadKind :keyword sku: Php workloads SKU. :paramtype sku: ~azure.mgmt.workloads.models.Sku @@ -3237,7 +3169,7 @@ def __init__( :keyword backup_profile: Backup profile. :paramtype backup_profile: ~azure.mgmt.workloads.models.BackupProfile """ - super(PhpWorkloadResource, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.kind = kind self.sku = sku self.identity = identity @@ -3262,40 +3194,39 @@ class PhpWorkloadResourceIdentity(UserAssignedServiceIdentity): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of manage identity. Possible values include: "None", "UserAssigned". + :ivar type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". :vartype type: str or ~azure.mgmt.workloads.models.ManagedServiceIdentityType :ivar user_assigned_identities: User assigned identities dictionary. :vartype user_assigned_identities: dict[str, ~azure.mgmt.workloads.models.UserAssignedIdentity] """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Union[str, "ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. Type of manage identity. Possible values include: "None", - "UserAssigned". + :keyword type: Type of manage identity. Required. Known values are: "None" and "UserAssigned". :paramtype type: str or ~azure.mgmt.workloads.models.ManagedServiceIdentityType :keyword user_assigned_identities: User assigned identities dictionary. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.workloads.models.UserAssignedIdentity] """ - super(PhpWorkloadResourceIdentity, self).__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) + super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) -class PhpWorkloadResourceList(msrest.serialization.Model): +class PhpWorkloadResourceList(_serialization.Model): """Php workload resource list. :ivar value: List of resources in current page. @@ -3305,16 +3236,12 @@ class PhpWorkloadResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PhpWorkloadResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PhpWorkloadResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PhpWorkloadResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PhpWorkloadResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of resources in current page. @@ -3322,7 +3249,7 @@ def __init__( :keyword next_link: Link to next page of resources. :paramtype next_link: str """ - super(PhpWorkloadResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -3332,8 +3259,7 @@ class PrometheusHaClusterProviderInstanceProperties(ProviderSpecificProperties): All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str :ivar prometheus_url: URL of the Node Exporter endpoint. :vartype prometheus_url: str @@ -3346,15 +3272,15 @@ class PrometheusHaClusterProviderInstanceProperties(ProviderSpecificProperties): """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'prometheus_url': {'key': 'prometheusUrl', 'type': 'str'}, - 'hostname': {'key': 'hostname', 'type': 'str'}, - 'sid': {'key': 'sid', 'type': 'str'}, - 'cluster_name': {'key': 'clusterName', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, + "prometheus_url": {"key": "prometheusUrl", "type": "str"}, + "hostname": {"key": "hostname", "type": "str"}, + "sid": {"key": "sid", "type": "str"}, + "cluster_name": {"key": "clusterName", "type": "str"}, } def __init__( @@ -3376,8 +3302,8 @@ def __init__( :keyword cluster_name: Gets or sets the clusterName. :paramtype cluster_name: str """ - super(PrometheusHaClusterProviderInstanceProperties, self).__init__(**kwargs) - self.provider_type = 'PrometheusHaCluster' # type: str + super().__init__(**kwargs) + self.provider_type = "PrometheusHaCluster" # type: str self.prometheus_url = prometheus_url self.hostname = hostname self.sid = sid @@ -3389,34 +3315,28 @@ class PrometheusOSProviderInstanceProperties(ProviderSpecificProperties): All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str :ivar prometheus_url: URL of the Node Exporter endpoint. :vartype prometheus_url: str """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'prometheus_url': {'key': 'prometheusUrl', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, + "prometheus_url": {"key": "prometheusUrl", "type": "str"}, } - def __init__( - self, - *, - prometheus_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prometheus_url: Optional[str] = None, **kwargs): """ :keyword prometheus_url: URL of the Node Exporter endpoint. :paramtype prometheus_url: str """ - super(PrometheusOSProviderInstanceProperties, self).__init__(**kwargs) - self.provider_type = 'PrometheusOS' # type: str + super().__init__(**kwargs) + self.provider_type = "PrometheusOS" # type: str self.prometheus_url = prometheus_url @@ -3439,26 +3359,22 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class ProviderInstance(ProxyResource): @@ -3479,8 +3395,8 @@ class ProviderInstance(ProxyResource): :vartype system_data: ~azure.mgmt.workloads.models.SystemData :ivar identity: Managed service identity (user assigned identities). :vartype identity: ~azure.mgmt.workloads.models.UserAssignedServiceIdentity - :ivar provisioning_state: State of provisioning of the provider instance. Possible values - include: "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: State of provisioning of the provider instance. Known values are: + "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.WorkloadMonitorProvisioningState :ivar errors: Defines the provider instance errors. @@ -3490,30 +3406,30 @@ class ProviderInstance(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'errors': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedServiceIdentity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'errors': {'key': 'properties.errors', 'type': 'ProviderInstancePropertiesErrors'}, - 'provider_settings': {'key': 'properties.providerSettings', 'type': 'ProviderSpecificProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "identity": {"key": "identity", "type": "UserAssignedServiceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "errors": {"key": "properties.errors", "type": "ProviderInstancePropertiesErrors"}, + "provider_settings": {"key": "properties.providerSettings", "type": "ProviderSpecificProperties"}, } def __init__( self, *, - identity: Optional["UserAssignedServiceIdentity"] = None, - provider_settings: Optional["ProviderSpecificProperties"] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, + provider_settings: Optional["_models.ProviderSpecificProperties"] = None, **kwargs ): """ @@ -3522,14 +3438,14 @@ def __init__( :keyword provider_settings: Defines the provider instance errors. :paramtype provider_settings: ~azure.mgmt.workloads.models.ProviderSpecificProperties """ - super(ProviderInstance, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.provisioning_state = None self.errors = None self.provider_settings = provider_settings -class ProviderInstanceListResult(msrest.serialization.Model): +class ProviderInstanceListResult(_serialization.Model): """The response from the List provider instances operation. :ivar value: The list of provider instances. @@ -3539,16 +3455,12 @@ class ProviderInstanceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProviderInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ProviderInstance"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ProviderInstance"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of provider instances. @@ -3556,7 +3468,7 @@ def __init__( :keyword next_link: The URL to get the next set of provider instances. :paramtype next_link: str """ - super(ProviderInstanceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -3580,31 +3492,27 @@ class ProviderInstancePropertiesErrors(Error): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'inner_error': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "inner_error": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'inner_error': {'key': 'innerError', 'type': 'ErrorInnerError'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[Error]"}, + "inner_error": {"key": "innerError", "type": "ErrorInnerError"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProviderInstancePropertiesErrors, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class RestrictionInfo(msrest.serialization.Model): +class RestrictionInfo(_serialization.Model): """The SKU restriction information. :ivar locations: The restriction locations. @@ -3614,30 +3522,24 @@ class RestrictionInfo(msrest.serialization.Model): """ _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - locations: Optional[List[str]] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, locations: Optional[List[str]] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword locations: The restriction locations. :paramtype locations: list[str] :keyword zones: The restriction zones. :paramtype zones: list[str] """ - super(RestrictionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.locations = locations self.zones = zones -class SAPApplicationServerInstance(TrackedResource): - """Define the SAP Application Server Instance. +class SAPApplicationServerInstance(TrackedResource): # pylint: disable=too-many-instance-attributes + """Define the SAP Application Server Instance resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3654,38 +3556,38 @@ class SAPApplicationServerInstance(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar instance_no: The application server instance id. + :ivar instance_no: Application server Instance Number. :vartype instance_no: str - :ivar subnet: The application server subnet. + :ivar subnet: Application server Subnet. :vartype subnet: str - :ivar hostname: The application server SAP host name. + :ivar hostname: Application server instance SAP hostname. :vartype hostname: str - :ivar kernel_version: The application server SAP kernel version. + :ivar kernel_version: Application server instance SAP Kernel Version. :vartype kernel_version: str - :ivar kernel_patch: The application server SAP kernel patch. + :ivar kernel_patch: Application server instance SAP Kernel Patch level. :vartype kernel_patch: str - :ivar ip_address: The application server SAP IP Address. + :ivar ip_address: Application server instance SAP IP Address. :vartype ip_address: str - :ivar gateway_port: The application server gateway Port. - :vartype gateway_port: long - :ivar icm_http_port: The application server ICM HTTP Port. - :vartype icm_http_port: long - :ivar icm_https_port: The application server ICM HTTPS Port. - :vartype icm_https_port: long + :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 virtual_machine_id: The virtual machine. :vartype virtual_machine_id: str - :ivar status: Defines the SAP Instance status. Possible values include: "Starting", "Running", - "Stopping", "Offline", "PartiallyRunning", "Unavailable". + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", and "Unavailable". :vartype status: str or ~azure.mgmt.workloads.models.SAPVirtualInstanceStatus - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". :vartype health: str or ~azure.mgmt.workloads.models.SAPHealthState - :ivar provisioning_state: Defines the provisioning states. Possible values include: - "Succeeded", "Updating", "Creating", "Failed", "Deleting". + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.SapVirtualInstanceProvisioningState :ivar errors: Defines the Application Instance errors. @@ -3693,64 +3595,58 @@ class SAPApplicationServerInstance(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - '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}, - 'virtual_machine_id': {'readonly': True}, - 'status': {'readonly': True}, - 'health': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'errors': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'instance_no': {'key': 'properties.instanceNo', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'str'}, - 'hostname': {'key': 'properties.hostname', 'type': 'str'}, - 'kernel_version': {'key': 'properties.kernelVersion', 'type': 'str'}, - 'kernel_patch': {'key': 'properties.kernelPatch', 'type': 'str'}, - 'ip_address': {'key': 'properties.ipAddress', 'type': 'str'}, - 'gateway_port': {'key': 'properties.gatewayPort', 'type': 'long'}, - 'icm_http_port': {'key': 'properties.icmHttpPort', 'type': 'long'}, - 'icm_https_port': {'key': 'properties.icmHttpsPort', 'type': 'long'}, - 'virtual_machine_id': {'key': 'properties.virtualMachineId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'health': {'key': 'properties.health', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'errors': {'key': 'properties.errors', 'type': 'SAPVirtualInstanceError'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "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}, + "virtual_machine_id": {"readonly": True}, + "status": {"readonly": True}, + "health": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - """ - :keyword tags: A set of tags. Resource tags. + _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"}, + "instance_no": {"key": "properties.instanceNo", "type": "str"}, + "subnet": {"key": "properties.subnet", "type": "str"}, + "hostname": {"key": "properties.hostname", "type": "str"}, + "kernel_version": {"key": "properties.kernelVersion", "type": "str"}, + "kernel_patch": {"key": "properties.kernelPatch", "type": "str"}, + "ip_address": {"key": "properties.ipAddress", "type": "str"}, + "gateway_port": {"key": "properties.gatewayPort", "type": "int"}, + "icm_http_port": {"key": "properties.icmHttpPort", "type": "int"}, + "icm_https_port": {"key": "properties.icmHttpsPort", "type": "int"}, + "virtual_machine_id": {"key": "properties.virtualMachineId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "health": {"key": "properties.health", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "errors": {"key": "properties.errors", "type": "SAPVirtualInstanceError"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(SAPApplicationServerInstance, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.instance_no = None self.subnet = None self.hostname = None @@ -3767,90 +3663,90 @@ def __init__( self.errors = None -class SAPApplicationServerInstanceList(msrest.serialization.Model): - """Defines the collection of SAP Application Server Instances. +class SAPApplicationServerInstanceList(_serialization.Model): + """Defines the collection of SAP Application Server Instance resources. - :ivar value: Gets the list of SAP Application Server instances. + :ivar value: Gets the list of SAP Application Server instance resources. :vartype value: list[~azure.mgmt.workloads.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'}, + "value": {"key": "value", "type": "[SAPApplicationServerInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SAPApplicationServerInstance"]] = None, + value: Optional[List["_models.SAPApplicationServerInstance"]] = None, next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Gets the list of SAP Application Server instances. + :keyword value: Gets the list of SAP Application Server instance resources. :paramtype value: list[~azure.mgmt.workloads.models.SAPApplicationServerInstance] :keyword next_link: Gets the value of next link. :paramtype next_link: str """ - super(SAPApplicationServerInstanceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SAPAvailabilityZoneDetailsRequest(msrest.serialization.Model): +class SAPAvailabilityZoneDetailsRequest(_serialization.Model): """The SAP request to get list of availability zones. All required parameters must be populated in order to send to Azure. - :ivar app_location: Required. The geo-location where the SAP resources will be created. + :ivar app_location: The geo-location where the SAP resources will be created. Required. :vartype app_location: str - :ivar sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". :vartype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :ivar database_type: Required. The database type. Eg: HANA, DB2, etc. Possible values include: - "HANA", "DB2". + :ivar database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: "HANA" + and "DB2". :vartype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType """ _validation = { - 'app_location': {'required': True}, - 'sap_product': {'required': True}, - 'database_type': {'required': True}, + "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'}, + "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, "SAPProductType"], - database_type: Union[str, "SAPDatabaseType"], + sap_product: Union[str, "_models.SAPProductType"], + database_type: Union[str, "_models.SAPDatabaseType"], **kwargs ): """ - :keyword app_location: Required. The geo-location where the SAP resources will be created. + :keyword app_location: The geo-location where the SAP resources will be created. Required. :paramtype app_location: str - :keyword sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". :paramtype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :keyword database_type: Required. The database type. Eg: HANA, DB2, etc. Possible values - include: "HANA", "DB2". + :keyword database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: + "HANA" and "DB2". :paramtype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType """ - super(SAPAvailabilityZoneDetailsRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_location = app_location self.sap_product = sap_product self.database_type = database_type -class SAPAvailabilityZoneDetailsResult(msrest.serialization.Model): +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. @@ -3858,89 +3754,78 @@ class SAPAvailabilityZoneDetailsResult(msrest.serialization.Model): """ _attribute_map = { - 'availability_zone_pairs': {'key': 'availabilityZonePairs', 'type': '[SAPAvailabilityZonePair]'}, + "availability_zone_pairs": {"key": "availabilityZonePairs", "type": "[SAPAvailabilityZonePair]"}, } - def __init__( - self, - *, - availability_zone_pairs: Optional[List["SAPAvailabilityZonePair"]] = None, - **kwargs - ): + def __init__(self, *, availability_zone_pairs: Optional[List["_models.SAPAvailabilityZonePair"]] = None, **kwargs): """ :keyword availability_zone_pairs: Gets the list of availability zone pairs. :paramtype availability_zone_pairs: list[~azure.mgmt.workloads.models.SAPAvailabilityZonePair] """ - super(SAPAvailabilityZoneDetailsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.availability_zone_pairs = availability_zone_pairs -class SAPAvailabilityZonePair(msrest.serialization.Model): +class SAPAvailabilityZonePair(_serialization.Model): """The SAP Availability Zone Pair. :ivar zone_a: The zone A. - :vartype zone_a: long + :vartype zone_a: int :ivar zone_b: The zone B. - :vartype zone_b: long + :vartype zone_b: int """ _attribute_map = { - 'zone_a': {'key': 'zoneA', 'type': 'long'}, - 'zone_b': {'key': 'zoneB', 'type': 'long'}, + "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 - ): + def __init__(self, *, zone_a: Optional[int] = None, zone_b: Optional[int] = None, **kwargs): """ :keyword zone_a: The zone A. - :paramtype zone_a: long + :paramtype zone_a: int :keyword zone_b: The zone B. - :paramtype zone_b: long + :paramtype zone_b: int """ - super(SAPAvailabilityZonePair, self).__init__(**kwargs) + super().__init__(**kwargs) self.zone_a = zone_a self.zone_b = zone_b -class SAPCentralInstanceList(msrest.serialization.Model): - """Defines the collection of SAP Central Instances. +class SAPCentralInstanceList(_serialization.Model): + """Defines the collection of SAP Central Services Instance resources. - :ivar value: Gets the list of SAP central instances. + :ivar value: Gets the list of SAP central services instance resources. :vartype value: list[~azure.mgmt.workloads.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'}, + "value": {"key": "value", "type": "[SAPCentralServerInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SAPCentralServerInstance"]] = None, + value: Optional[List["_models.SAPCentralServerInstance"]] = None, next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Gets the list of SAP central instances. + :keyword value: Gets the list of SAP central services instance resources. :paramtype value: list[~azure.mgmt.workloads.models.SAPCentralServerInstance] :keyword next_link: Gets the value of next link. :paramtype next_link: str """ - super(SAPCentralInstanceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SAPCentralServerInstance(TrackedResource): - """Define the SAP Central Server Instance. +class SAPCentralServerInstance(TrackedResource): # pylint: disable=too-many-instance-attributes + """Define the SAP Central Services Instance resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3957,80 +3842,84 @@ class SAPCentralServerInstance(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar instance_no: The central server instance id. + :ivar instance_no: The central services instance number. :vartype instance_no: str - :ivar subnet: The central server subnet. + :ivar subnet: The central services instance subnet. :vartype subnet: str - :ivar message_server_properties: Defines the SAP message server properties. + :ivar message_server_properties: Defines the SAP Message Server properties. :vartype message_server_properties: ~azure.mgmt.workloads.models.MessageServerProperties - :ivar enqueue_server_properties: Defines the SAP enqueue server properties. + :ivar enqueue_server_properties: Defines the SAP Enqueue Server properties. :vartype enqueue_server_properties: ~azure.mgmt.workloads.models.EnqueueServerProperties :ivar gateway_server_properties: Defines the SAP Gateway Server properties. :vartype gateway_server_properties: ~azure.mgmt.workloads.models.GatewayServerProperties - :ivar enqueue_replication_server_properties: Defines the SAP ERS Server properties. + :ivar enqueue_replication_server_properties: Defines the SAP Enqueue Replication Server (ERS) + properties. :vartype enqueue_replication_server_properties: ~azure.mgmt.workloads.models.EnqueueReplicationServerProperties - :ivar kernel_version: The central server kernel version. + :ivar kernel_version: The central services instance Kernel Version. :vartype kernel_version: str - :ivar kernel_patch: The central server kernel patch. + :ivar kernel_patch: The central services instance Kernel Patch level. :vartype kernel_patch: str - :ivar vm_details: The list of virtual machines. + :ivar vm_details: The list of virtual machines corresponding to the Central Services instance. :vartype vm_details: list[~azure.mgmt.workloads.models.CentralServerVmDetails] - :ivar status: Defines the SAP Instance status. Possible values include: "Starting", "Running", - "Stopping", "Offline", "PartiallyRunning", "Unavailable". + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", and "Unavailable". :vartype status: str or ~azure.mgmt.workloads.models.SAPVirtualInstanceStatus - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". :vartype health: str or ~azure.mgmt.workloads.models.SAPHealthState - :ivar provisioning_state: Defines the provisioning states. Possible values include: - "Succeeded", "Updating", "Creating", "Failed", "Deleting". + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.SapVirtualInstanceProvisioningState - :ivar errors: Defines the Central Instance errors. + :ivar errors: Defines the errors related to SAP Central Services Instance resource. :vartype errors: ~azure.mgmt.workloads.models.SAPVirtualInstanceError """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'instance_no': {'readonly': True}, - 'subnet': {'readonly': True}, - 'kernel_version': {'readonly': True}, - 'kernel_patch': {'readonly': True}, - 'vm_details': {'readonly': True}, - 'status': {'readonly': True}, - 'health': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'errors': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'instance_no': {'key': 'properties.instanceNo', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'str'}, - 'message_server_properties': {'key': 'properties.messageServerProperties', 'type': 'MessageServerProperties'}, - 'enqueue_server_properties': {'key': 'properties.enqueueServerProperties', 'type': 'EnqueueServerProperties'}, - 'gateway_server_properties': {'key': 'properties.gatewayServerProperties', 'type': 'GatewayServerProperties'}, - 'enqueue_replication_server_properties': {'key': 'properties.enqueueReplicationServerProperties', 'type': 'EnqueueReplicationServerProperties'}, - 'kernel_version': {'key': 'properties.kernelVersion', 'type': 'str'}, - 'kernel_patch': {'key': 'properties.kernelPatch', 'type': 'str'}, - 'vm_details': {'key': 'properties.vmDetails', 'type': '[CentralServerVmDetails]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'health': {'key': 'properties.health', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'errors': {'key': 'properties.errors', 'type': 'SAPVirtualInstanceError'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "instance_no": {"readonly": True}, + "subnet": {"readonly": True}, + "kernel_version": {"readonly": True}, + "kernel_patch": {"readonly": True}, + "vm_details": {"readonly": True}, + "status": {"readonly": True}, + "health": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "instance_no": {"key": "properties.instanceNo", "type": "str"}, + "subnet": {"key": "properties.subnet", "type": "str"}, + "message_server_properties": {"key": "properties.messageServerProperties", "type": "MessageServerProperties"}, + "enqueue_server_properties": {"key": "properties.enqueueServerProperties", "type": "EnqueueServerProperties"}, + "gateway_server_properties": {"key": "properties.gatewayServerProperties", "type": "GatewayServerProperties"}, + "enqueue_replication_server_properties": { + "key": "properties.enqueueReplicationServerProperties", + "type": "EnqueueReplicationServerProperties", + }, + "kernel_version": {"key": "properties.kernelVersion", "type": "str"}, + "kernel_patch": {"key": "properties.kernelPatch", "type": "str"}, + "vm_details": {"key": "properties.vmDetails", "type": "[CentralServerVmDetails]"}, + "status": {"key": "properties.status", "type": "str"}, + "health": {"key": "properties.health", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "errors": {"key": "properties.errors", "type": "SAPVirtualInstanceError"}, } def __init__( @@ -4038,28 +3927,29 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - message_server_properties: Optional["MessageServerProperties"] = None, - enqueue_server_properties: Optional["EnqueueServerProperties"] = None, - gateway_server_properties: Optional["GatewayServerProperties"] = None, - enqueue_replication_server_properties: Optional["EnqueueReplicationServerProperties"] = None, + 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 ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword message_server_properties: Defines the SAP message server properties. + :keyword message_server_properties: Defines the SAP Message Server properties. :paramtype message_server_properties: ~azure.mgmt.workloads.models.MessageServerProperties - :keyword enqueue_server_properties: Defines the SAP enqueue server properties. + :keyword enqueue_server_properties: Defines the SAP Enqueue Server properties. :paramtype enqueue_server_properties: ~azure.mgmt.workloads.models.EnqueueServerProperties :keyword gateway_server_properties: Defines the SAP Gateway Server properties. :paramtype gateway_server_properties: ~azure.mgmt.workloads.models.GatewayServerProperties - :keyword enqueue_replication_server_properties: Defines the SAP ERS Server properties. + :keyword enqueue_replication_server_properties: Defines the SAP Enqueue Replication Server + (ERS) properties. :paramtype enqueue_replication_server_properties: ~azure.mgmt.workloads.models.EnqueueReplicationServerProperties """ - super(SAPCentralServerInstance, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.instance_no = None self.subnet = None self.message_server_properties = message_server_properties @@ -4075,8 +3965,8 @@ def __init__( self.errors = None -class SAPDatabaseInstance(TrackedResource): - """Define the SAP Database Instance. +class SAPDatabaseInstance(TrackedResource): # pylint: disable=too-many-instance-attributes + """Define the Database resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4093,78 +3983,73 @@ class SAPDatabaseInstance(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar subnet: The database subnet. + :ivar subnet: Database subnet. :vartype subnet: str - :ivar database_sid: The database SID. + :ivar database_sid: Database SID name. :vartype database_sid: str - :ivar database_type: The SAP database type. + :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: The database IP Address. + :ivar ip_address: Database IP Address. :vartype ip_address: str - :ivar vm_details: The list of virtual machines. + :ivar vm_details: The list of virtual machines corresponding to the Database resource. :vartype vm_details: list[~azure.mgmt.workloads.models.DatabaseVmDetails] - :ivar status: Defines the SAP Instance status. Possible values include: "Starting", "Running", - "Stopping", "Offline", "PartiallyRunning", "Unavailable". + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", and "Unavailable". :vartype status: str or ~azure.mgmt.workloads.models.SAPVirtualInstanceStatus - :ivar provisioning_state: Defines the provisioning states. Possible values include: - "Succeeded", "Updating", "Creating", "Failed", "Deleting". + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.SapVirtualInstanceProvisioningState - :ivar errors: Defines the Database Instance errors. + :ivar errors: Defines the errors related to Database resource. :vartype errors: ~azure.mgmt.workloads.models.SAPVirtualInstanceError """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'subnet': {'readonly': True}, - 'database_sid': {'readonly': True}, - 'database_type': {'readonly': True}, - 'ip_address': {'readonly': True}, - 'vm_details': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'errors': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'str'}, - 'database_sid': {'key': 'properties.databaseSid', 'type': 'str'}, - 'database_type': {'key': 'properties.databaseType', 'type': 'str'}, - 'ip_address': {'key': 'properties.ipAddress', 'type': 'str'}, - 'vm_details': {'key': 'properties.vmDetails', 'type': '[DatabaseVmDetails]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'errors': {'key': 'properties.errors', 'type': 'SAPVirtualInstanceError'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "subnet": {"readonly": True}, + "database_sid": {"readonly": True}, + "database_type": {"readonly": True}, + "ip_address": {"readonly": True}, + "vm_details": {"readonly": True}, + "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "errors": {"readonly": True}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - """ - :keyword tags: A set of tags. Resource tags. + _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"}, + "subnet": {"key": "properties.subnet", "type": "str"}, + "database_sid": {"key": "properties.databaseSid", "type": "str"}, + "database_type": {"key": "properties.databaseType", "type": "str"}, + "ip_address": {"key": "properties.ipAddress", "type": "str"}, + "vm_details": {"key": "properties.vmDetails", "type": "[DatabaseVmDetails]"}, + "status": {"key": "properties.status", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "errors": {"key": "properties.errors", "type": "SAPVirtualInstanceError"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(SAPDatabaseInstance, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.subnet = None self.database_sid = None self.database_type = None @@ -4175,7 +4060,7 @@ def __init__( self.errors = None -class SAPDatabaseInstanceList(msrest.serialization.Model): +class SAPDatabaseInstanceList(_serialization.Model): """Defines the collection of SAP Database Instances. :ivar value: Gets the list of SAP Database instances. @@ -4185,16 +4070,12 @@ class SAPDatabaseInstanceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SAPDatabaseInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SAPDatabaseInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["SAPDatabaseInstance"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SAPDatabaseInstance"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Gets the list of SAP Database instances. @@ -4202,12 +4083,12 @@ def __init__( :keyword next_link: Gets the value of next link. :paramtype next_link: str """ - super(SAPDatabaseInstanceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SAPDiskConfiguration(msrest.serialization.Model): +class SAPDiskConfiguration(_serialization.Model): """The SAP Disk Configuration. :ivar volume: The volume name. @@ -4215,25 +4096,25 @@ class SAPDiskConfiguration(msrest.serialization.Model): :ivar disk_type: The disk type. :vartype disk_type: str :ivar disk_count: The disk count. - :vartype disk_count: long + :vartype disk_count: int :ivar disk_size_gb: The disk size in GB. - :vartype disk_size_gb: long + :vartype disk_size_gb: int :ivar disk_iops_read_write: The disk Iops. - :vartype disk_iops_read_write: long + :vartype disk_iops_read_write: int :ivar disk_m_bps_read_write: The disk provisioned throughput in MBps. - :vartype disk_m_bps_read_write: long + :vartype disk_m_bps_read_write: int :ivar disk_storage_type: The disk storage type. :vartype disk_storage_type: str """ _attribute_map = { - 'volume': {'key': 'volume', 'type': 'str'}, - 'disk_type': {'key': 'diskType', 'type': 'str'}, - 'disk_count': {'key': 'diskCount', 'type': 'long'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'long'}, - 'disk_iops_read_write': {'key': 'diskIopsReadWrite', 'type': 'long'}, - 'disk_m_bps_read_write': {'key': 'diskMBpsReadWrite', 'type': 'long'}, - 'disk_storage_type': {'key': 'diskStorageType', 'type': 'str'}, + "volume": {"key": "volume", "type": "str"}, + "disk_type": {"key": "diskType", "type": "str"}, + "disk_count": {"key": "diskCount", "type": "int"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "disk_iops_read_write": {"key": "diskIopsReadWrite", "type": "int"}, + "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, + "disk_storage_type": {"key": "diskStorageType", "type": "str"}, } def __init__( @@ -4254,17 +4135,17 @@ def __init__( :keyword disk_type: The disk type. :paramtype disk_type: str :keyword disk_count: The disk count. - :paramtype disk_count: long + :paramtype disk_count: int :keyword disk_size_gb: The disk size in GB. - :paramtype disk_size_gb: long + :paramtype disk_size_gb: int :keyword disk_iops_read_write: The disk Iops. - :paramtype disk_iops_read_write: long + :paramtype disk_iops_read_write: int :keyword disk_m_bps_read_write: The disk provisioned throughput in MBps. - :paramtype disk_m_bps_read_write: long + :paramtype disk_m_bps_read_write: int :keyword disk_storage_type: The disk storage type. :paramtype disk_storage_type: str """ - super(SAPDiskConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.volume = volume self.disk_type = disk_type self.disk_count = disk_count @@ -4274,77 +4155,77 @@ def __init__( self.disk_storage_type = disk_storage_type -class SAPDiskConfigurationsRequest(msrest.serialization.Model): +class SAPDiskConfigurationsRequest(_serialization.Model): """The SAP request to get list of disk configurations. All required parameters must be populated in order to send to Azure. - :ivar app_location: Required. The geo-location where the SAP resources will be created. + :ivar app_location: The geo-location where the SAP resources will be created. Required. :vartype app_location: str - :ivar environment: Required. Defines the environment type - Production/Non Production. Possible - values include: "NonProd", "Prod". + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :vartype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :ivar sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". :vartype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :ivar database_type: Required. The database type. Eg: HANA, DB2, etc. Possible values include: - "HANA", "DB2". + :ivar database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: "HANA" + and "DB2". :vartype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :ivar deployment_type: Required. The deployment type. Eg: SingleServer/ThreeTier. Possible - values include: "SingleServer", "ThreeTier". + :ivar deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known values + are: "SingleServer" and "ThreeTier". :vartype deployment_type: str or ~azure.mgmt.workloads.models.SAPDeploymentType - :ivar db_vm_sku: Required. The VM SKU for database instance. + :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}, + "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'}, + "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, "SAPEnvironmentType"], - sap_product: Union[str, "SAPProductType"], - database_type: Union[str, "SAPDatabaseType"], - deployment_type: Union[str, "SAPDeploymentType"], + 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 ): """ - :keyword app_location: Required. The geo-location where the SAP resources will be created. + :keyword app_location: The geo-location where the SAP resources will be created. Required. :paramtype app_location: str - :keyword environment: Required. Defines the environment type - Production/Non Production. - Possible values include: "NonProd", "Prod". + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :paramtype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :keyword sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". :paramtype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :keyword database_type: Required. The database type. Eg: HANA, DB2, etc. Possible values - include: "HANA", "DB2". + :keyword database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: + "HANA" and "DB2". :paramtype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :keyword deployment_type: Required. The deployment type. Eg: SingleServer/ThreeTier. Possible - values include: "SingleServer", "ThreeTier". + :keyword deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known + values are: "SingleServer" and "ThreeTier". :paramtype deployment_type: str or ~azure.mgmt.workloads.models.SAPDeploymentType - :keyword db_vm_sku: Required. The VM SKU for database instance. + :keyword db_vm_sku: The VM SKU for database instance. Required. :paramtype db_vm_sku: str """ - super(SAPDiskConfigurationsRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_location = app_location self.environment = environment self.sap_product = sap_product @@ -4353,7 +4234,7 @@ def __init__( self.db_vm_sku = db_vm_sku -class SAPDiskConfigurationsResult(msrest.serialization.Model): +class SAPDiskConfigurationsResult(_serialization.Model): """The list of disk configuration for vmSku which are part of SAP deployment. :ivar disk_configurations: Gets the list of Disk Configurations. @@ -4361,73 +4242,32 @@ class SAPDiskConfigurationsResult(msrest.serialization.Model): """ _attribute_map = { - 'disk_configurations': {'key': 'diskConfigurations', 'type': '[SAPDiskConfiguration]'}, + "disk_configurations": {"key": "diskConfigurations", "type": "[SAPDiskConfiguration]"}, } - def __init__( - self, - *, - disk_configurations: Optional[List["SAPDiskConfiguration"]] = None, - **kwargs - ): + def __init__(self, *, disk_configurations: Optional[List["_models.SAPDiskConfiguration"]] = None, **kwargs): """ :keyword disk_configurations: Gets the list of Disk Configurations. :paramtype disk_configurations: list[~azure.mgmt.workloads.models.SAPDiskConfiguration] """ - super(SAPDiskConfigurationsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.disk_configurations = disk_configurations -class SoftwareConfiguration(msrest.serialization.Model): - """The SAP Software configuration Input. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SAPInstallWithoutOSConfigSoftwareConfiguration, ServiceInitiatedSoftwareConfiguration. - - All required parameters must be populated in order to send to Azure. - - :ivar software_installation_type: Required. The SAP software installation Type.Constant filled - by server. Possible values include: "ServiceInitiated", "SAPInstallWithoutOSConfig". - :vartype software_installation_type: str or - ~azure.mgmt.workloads.models.SAPSoftwareInstallationType - """ - - _validation = { - 'software_installation_type': {'required': True}, - } - - _attribute_map = { - 'software_installation_type': {'key': 'softwareInstallationType', 'type': 'str'}, - } - - _subtype_map = { - 'software_installation_type': {'SAPInstallWithoutOSConfig': 'SAPInstallWithoutOSConfigSoftwareConfiguration', 'ServiceInitiated': 'ServiceInitiatedSoftwareConfiguration'} - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(SoftwareConfiguration, self).__init__(**kwargs) - self.software_installation_type = None # type: Optional[str] - - class SAPInstallWithoutOSConfigSoftwareConfiguration(SoftwareConfiguration): """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 Azure. - :ivar software_installation_type: Required. The SAP software installation Type.Constant filled - by server. Possible values include: "ServiceInitiated", "SAPInstallWithoutOSConfig". + :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.workloads.models.SAPSoftwareInstallationType - :ivar bom_url: Required. The URL to the SAP Build of Materials(BOM) file. + :ivar bom_url: The URL to the SAP Build of Materials(BOM) file. Required. :vartype bom_url: str - :ivar sap_bits_storage_account_id: Required. The SAP bits storage account id. + :ivar sap_bits_storage_account_id: The SAP bits storage account id. Required. :vartype sap_bits_storage_account_id: str - :ivar software_version: Required. The software version to install. + :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: @@ -4435,18 +4275,21 @@ class SAPInstallWithoutOSConfigSoftwareConfiguration(SoftwareConfiguration): """ _validation = { - 'software_installation_type': {'required': True}, - 'bom_url': {'required': True}, - 'sap_bits_storage_account_id': {'required': True}, - 'software_version': {'required': True}, + "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'}, + "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__( @@ -4455,35 +4298,36 @@ def __init__( bom_url: str, sap_bits_storage_account_id: str, software_version: str, - high_availability_software_configuration: Optional["HighAvailabilitySoftwareConfiguration"] = None, + high_availability_software_configuration: Optional["_models.HighAvailabilitySoftwareConfiguration"] = None, **kwargs ): """ - :keyword bom_url: Required. The URL to the SAP Build of Materials(BOM) file. + :keyword bom_url: The URL to the SAP Build of Materials(BOM) file. Required. :paramtype bom_url: str - :keyword sap_bits_storage_account_id: Required. The SAP bits storage account id. + :keyword sap_bits_storage_account_id: The SAP bits storage account id. Required. :paramtype sap_bits_storage_account_id: str - :keyword software_version: Required. The software version to install. + :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.workloads.models.HighAvailabilitySoftwareConfiguration """ - super(SAPInstallWithoutOSConfigSoftwareConfiguration, self).__init__(**kwargs) - self.software_installation_type = 'SAPInstallWithoutOSConfig' # type: str + super().__init__(**kwargs) + self.software_installation_type = "SAPInstallWithoutOSConfig" # type: str 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 SapNetWeaverProviderInstanceProperties(ProviderSpecificProperties): +class SapNetWeaverProviderInstanceProperties( + ProviderSpecificProperties +): # pylint: disable=too-many-instance-attributes """Gets or sets the provider properties. All required parameters must be populated in order to send to Azure. - :ivar provider_type: Required. The provider type. For example, the value can be - SapHana.Constant filled by server. + :ivar provider_type: The provider type. For example, the value can be SapHana. Required. :vartype provider_type: str :ivar sap_sid: Gets or sets the SAP System Identifier. :vartype sap_sid: str @@ -4508,21 +4352,21 @@ class SapNetWeaverProviderInstanceProperties(ProviderSpecificProperties): """ _validation = { - 'provider_type': {'required': True}, + "provider_type": {"required": True}, } _attribute_map = { - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'sap_sid': {'key': 'sapSid', 'type': 'str'}, - 'sap_hostname': {'key': 'sapHostname', 'type': 'str'}, - 'sap_instance_nr': {'key': 'sapInstanceNr', 'type': 'str'}, - 'sap_host_file_entries': {'key': 'sapHostFileEntries', 'type': '[str]'}, - 'sap_username': {'key': 'sapUsername', 'type': 'str'}, - 'sap_password': {'key': 'sapPassword', 'type': 'str'}, - 'sap_password_uri': {'key': 'sapPasswordUri', 'type': 'str'}, - 'sap_client_id': {'key': 'sapClientId', 'type': 'str'}, - 'sap_port_number': {'key': 'sapPortNumber', 'type': 'str'}, - 'sap_ssl_certificate_uri': {'key': 'sapSslCertificateUri', 'type': 'str'}, + "provider_type": {"key": "providerType", "type": "str"}, + "sap_sid": {"key": "sapSid", "type": "str"}, + "sap_hostname": {"key": "sapHostname", "type": "str"}, + "sap_instance_nr": {"key": "sapInstanceNr", "type": "str"}, + "sap_host_file_entries": {"key": "sapHostFileEntries", "type": "[str]"}, + "sap_username": {"key": "sapUsername", "type": "str"}, + "sap_password": {"key": "sapPassword", "type": "str"}, + "sap_password_uri": {"key": "sapPasswordUri", "type": "str"}, + "sap_client_id": {"key": "sapClientId", "type": "str"}, + "sap_port_number": {"key": "sapPortNumber", "type": "str"}, + "sap_ssl_certificate_uri": {"key": "sapSslCertificateUri", "type": "str"}, } def __init__( @@ -4563,8 +4407,8 @@ def __init__( system. :paramtype sap_ssl_certificate_uri: str """ - super(SapNetWeaverProviderInstanceProperties, self).__init__(**kwargs) - self.provider_type = 'SapNetWeaver' # type: str + super().__init__(**kwargs) + self.provider_type = "SapNetWeaver" # type: str self.sap_sid = sap_sid self.sap_hostname = sap_hostname self.sap_instance_nr = sap_instance_nr @@ -4577,96 +4421,96 @@ def __init__( self.sap_ssl_certificate_uri = sap_ssl_certificate_uri -class SAPSizingRecommendationRequest(msrest.serialization.Model): +class SAPSizingRecommendationRequest(_serialization.Model): """The SAP Sizing Recommendation request. All required parameters must be populated in order to send to Azure. - :ivar app_location: Required. The geo-location where the resource is to be created. + :ivar app_location: The geo-location where the resource is to be created. Required. :vartype app_location: str - :ivar environment: Required. Defines the environment type - Production/Non Production. Possible - values include: "NonProd", "Prod". + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :vartype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :ivar sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". :vartype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :ivar deployment_type: Required. The deployment type. Eg: SingleServer/ThreeTier. Possible - values include: "SingleServer", "ThreeTier". + :ivar deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known values + are: "SingleServer" and "ThreeTier". :vartype deployment_type: str or ~azure.mgmt.workloads.models.SAPDeploymentType - :ivar saps: Required. The SAP Application Performance Standard measurement. - :vartype saps: long - :ivar db_memory: Required. The database memory configuration. - :vartype db_memory: long - :ivar database_type: Required. The database type. Possible values include: "HANA", "DB2". + :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.workloads.models.SAPDatabaseType - :ivar db_scale_method: The DB scale method. Possible values include: "ScaleUp". + :ivar db_scale_method: The DB scale method. "ScaleUp" :vartype db_scale_method: str or ~azure.mgmt.workloads.models.SAPDatabaseScaleMethod - :ivar high_availability_type: The high availability type. Possible values include: - "AvailabilitySet", "AvailabilityZone". + :ivar high_availability_type: The high availability type. Known values are: "AvailabilitySet" + and "AvailabilityZone". :vartype high_availability_type: str or ~azure.mgmt.workloads.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}, + "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': 'long'}, - 'db_memory': {'key': 'dbMemory', 'type': 'long'}, - 'database_type': {'key': 'databaseType', 'type': 'str'}, - 'db_scale_method': {'key': 'dbScaleMethod', 'type': 'str'}, - 'high_availability_type': {'key': 'highAvailabilityType', 'type': 'str'}, + "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, "SAPEnvironmentType"], - sap_product: Union[str, "SAPProductType"], - deployment_type: Union[str, "SAPDeploymentType"], + 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, "SAPDatabaseType"], - db_scale_method: Optional[Union[str, "SAPDatabaseScaleMethod"]] = None, - high_availability_type: Optional[Union[str, "SAPHighAvailabilityType"]] = None, + 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 ): """ - :keyword app_location: Required. The geo-location where the resource is to be created. + :keyword app_location: The geo-location where the resource is to be created. Required. :paramtype app_location: str - :keyword environment: Required. Defines the environment type - Production/Non Production. - Possible values include: "NonProd", "Prod". + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :paramtype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :keyword sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". :paramtype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :keyword deployment_type: Required. The deployment type. Eg: SingleServer/ThreeTier. Possible - values include: "SingleServer", "ThreeTier". + :keyword deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known + values are: "SingleServer" and "ThreeTier". :paramtype deployment_type: str or ~azure.mgmt.workloads.models.SAPDeploymentType - :keyword saps: Required. The SAP Application Performance Standard measurement. - :paramtype saps: long - :keyword db_memory: Required. The database memory configuration. - :paramtype db_memory: long - :keyword database_type: Required. The database type. Possible values include: "HANA", "DB2". + :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.workloads.models.SAPDatabaseType - :keyword db_scale_method: The DB scale method. Possible values include: "ScaleUp". + :keyword db_scale_method: The DB scale method. "ScaleUp" :paramtype db_scale_method: str or ~azure.mgmt.workloads.models.SAPDatabaseScaleMethod - :keyword high_availability_type: The high availability type. Possible values include: - "AvailabilitySet", "AvailabilityZone". + :keyword high_availability_type: The high availability type. Known values are: + "AvailabilitySet" and "AvailabilityZone". :paramtype high_availability_type: str or ~azure.mgmt.workloads.models.SAPHighAvailabilityType """ - super(SAPSizingRecommendationRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_location = app_location self.environment = environment self.sap_product = sap_product @@ -4678,42 +4522,41 @@ def __init__( self.high_availability_type = high_availability_type -class SAPSizingRecommendationResult(msrest.serialization.Model): +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. + 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 Azure. - :ivar deployment_type: Required. The deployment Type.Constant filled by server. Possible values - include: "SingleServer", "ThreeTier". + :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.workloads.models.SAPDeploymentType """ _validation = { - 'deployment_type': {'required': True}, + "deployment_type": {"required": True}, } _attribute_map = { - 'deployment_type': {'key': 'deploymentType', 'type': 'str'}, + "deployment_type": {"key": "deploymentType", "type": "str"}, } _subtype_map = { - 'deployment_type': {'SingleServer': 'SingleServerRecommendationResult', 'ThreeTier': 'ThreeTierRecommendationResult'} + "deployment_type": { + "SingleServer": "SingleServerRecommendationResult", + "ThreeTier": "ThreeTierRecommendationResult", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(SAPSizingRecommendationResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.deployment_type = None # type: Optional[str] -class SAPSupportedResourceSkusResult(msrest.serialization.Model): +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. @@ -4721,24 +4564,19 @@ class SAPSupportedResourceSkusResult(msrest.serialization.Model): """ _attribute_map = { - 'supported_skus': {'key': 'supportedSkus', 'type': '[SAPSupportedSku]'}, + "supported_skus": {"key": "supportedSkus", "type": "[SAPSupportedSku]"}, } - def __init__( - self, - *, - supported_skus: Optional[List["SAPSupportedSku"]] = None, - **kwargs - ): + def __init__(self, *, supported_skus: Optional[List["_models.SAPSupportedSku"]] = None, **kwargs): """ :keyword supported_skus: Gets the list of SAP supported SKUs. :paramtype supported_skus: list[~azure.mgmt.workloads.models.SAPSupportedSku] """ - super(SAPSupportedResourceSkusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.supported_skus = supported_skus -class SAPSupportedSku(msrest.serialization.Model): +class SAPSupportedSku(_serialization.Model): """The SAP supported SKU. :ivar vm_sku: The VM Sku. @@ -4751,9 +4589,9 @@ class SAPSupportedSku(msrest.serialization.Model): """ _attribute_map = { - 'vm_sku': {'key': 'vmSku', 'type': 'str'}, - 'is_app_server_certified': {'key': 'isAppServerCertified', 'type': 'bool'}, - 'is_database_certified': {'key': 'isDatabaseCertified', 'type': 'bool'}, + "vm_sku": {"key": "vmSku", "type": "str"}, + "is_app_server_certified": {"key": "isAppServerCertified", "type": "bool"}, + "is_database_certified": {"key": "isDatabaseCertified", "type": "bool"}, } def __init__( @@ -4774,84 +4612,84 @@ def __init__( system. :paramtype is_database_certified: bool """ - super(SAPSupportedSku, self).__init__(**kwargs) + 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(msrest.serialization.Model): +class SAPSupportedSkusRequest(_serialization.Model): """The SAP request to get list of supported SKUs. All required parameters must be populated in order to send to Azure. - :ivar app_location: Required. The geo-location where the resource is to be created. + :ivar app_location: The geo-location where the resource is to be created. Required. :vartype app_location: str - :ivar environment: Required. Defines the environment type - Production/Non Production. Possible - values include: "NonProd", "Prod". + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :vartype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :ivar sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". :vartype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :ivar deployment_type: Required. The deployment type. Eg: SingleServer/ThreeTier. Possible - values include: "SingleServer", "ThreeTier". + :ivar deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known values + are: "SingleServer" and "ThreeTier". :vartype deployment_type: str or ~azure.mgmt.workloads.models.SAPDeploymentType - :ivar database_type: Required. The database type. Eg: HANA, DB2, etc. Possible values include: - "HANA", "DB2". + :ivar database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: "HANA" + and "DB2". :vartype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :ivar high_availability_type: The high availability type. Possible values include: - "AvailabilitySet", "AvailabilityZone". + :ivar high_availability_type: The high availability type. Known values are: "AvailabilitySet" + and "AvailabilityZone". :vartype high_availability_type: str or ~azure.mgmt.workloads.models.SAPHighAvailabilityType """ _validation = { - 'app_location': {'required': True}, - 'environment': {'required': True}, - 'sap_product': {'required': True}, - 'deployment_type': {'required': True}, - 'database_type': {'required': True}, + "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'}, + "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, "SAPEnvironmentType"], - sap_product: Union[str, "SAPProductType"], - deployment_type: Union[str, "SAPDeploymentType"], - database_type: Union[str, "SAPDatabaseType"], - high_availability_type: Optional[Union[str, "SAPHighAvailabilityType"]] = None, + 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 ): """ - :keyword app_location: Required. The geo-location where the resource is to be created. + :keyword app_location: The geo-location where the resource is to be created. Required. :paramtype app_location: str - :keyword environment: Required. Defines the environment type - Production/Non Production. - Possible values include: "NonProd", "Prod". + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :paramtype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :keyword sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". :paramtype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :keyword deployment_type: Required. The deployment type. Eg: SingleServer/ThreeTier. Possible - values include: "SingleServer", "ThreeTier". + :keyword deployment_type: The deployment type. Eg: SingleServer/ThreeTier. Required. Known + values are: "SingleServer" and "ThreeTier". :paramtype deployment_type: str or ~azure.mgmt.workloads.models.SAPDeploymentType - :keyword database_type: Required. The database type. Eg: HANA, DB2, etc. Possible values - include: "HANA", "DB2". + :keyword database_type: The database type. Eg: HANA, DB2, etc. Required. Known values are: + "HANA" and "DB2". :paramtype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :keyword high_availability_type: The high availability type. Possible values include: - "AvailabilitySet", "AvailabilityZone". + :keyword high_availability_type: The high availability type. Known values are: + "AvailabilitySet" and "AvailabilityZone". :paramtype high_availability_type: str or ~azure.mgmt.workloads.models.SAPHighAvailabilityType """ - super(SAPSupportedSkusRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_location = app_location self.environment = environment self.sap_product = sap_product @@ -4860,8 +4698,8 @@ def __init__( self.high_availability_type = high_availability_type -class SAPVirtualInstance(TrackedResource): - """Define the Virtual Instance for SAP. +class SAPVirtualInstance(TrackedResource): # pylint: disable=too-many-instance-attributes + """Define the Virtual Instance for SAP solutions resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4878,112 +4716,116 @@ class SAPVirtualInstance(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :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.workloads.models.UserAssignedServiceIdentity - :ivar environment: Required. Defines the environment type - Production/Non Production. Possible - values include: "NonProd", "Prod". + :ivar environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :vartype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :ivar sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :ivar sap_product: Defines the SAP Product type. Required. Known values are: "ECC", "S4HANA", + and "Other". :vartype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :ivar configuration: Required. Defines if an existing SAP system is being registered or a new - SAP system is being created. + :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.workloads.models.SAPConfiguration :ivar managed_resource_group_configuration: Managed resource group configuration. :vartype managed_resource_group_configuration: ~azure.mgmt.workloads.models.ManagedRGConfiguration - :ivar status: Defines the SAP Instance status. Possible values include: "Starting", "Running", - "Stopping", "Offline", "PartiallyRunning", "Unavailable". + :ivar status: Defines the SAP Instance status. Known values are: "Starting", "Running", + "Stopping", "Offline", "PartiallyRunning", and "Unavailable". :vartype status: str or ~azure.mgmt.workloads.models.SAPVirtualInstanceStatus - :ivar health: Defines the SAP Instance health. Possible values include: "Unknown", "Healthy", - "Unhealthy", "Degraded". + :ivar health: Defines the health of SAP Instances. Known values are: "Unknown", "Healthy", + "Unhealthy", and "Degraded". :vartype health: str or ~azure.mgmt.workloads.models.SAPHealthState - :ivar state: Defines the Virtual Instance for SAP state. Possible values include: + :ivar state: Defines the Virtual Instance for SAP state. Known values are: "InfrastructureDeploymentPending", "InfrastructureDeploymentInProgress", "InfrastructureDeploymentFailed", "SoftwareInstallationPending", - "SoftwareInstallationInProgress", "SoftwareInstallationFailed", "DiscoveryPending", - "DiscoveryInProgress", "DiscoveryFailed", "RegistrationComplete". + "SoftwareInstallationInProgress", "SoftwareInstallationFailed", "SoftwareDetectionInProgress", + "SoftwareDetectionFailed", "DiscoveryPending", "DiscoveryInProgress", "DiscoveryFailed", and + "RegistrationComplete". :vartype state: str or ~azure.mgmt.workloads.models.SAPVirtualInstanceState - :ivar provisioning_state: Defines the provisioning states. Possible values include: - "Succeeded", "Updating", "Creating", "Failed", "Deleting". + :ivar provisioning_state: Defines the provisioning states. Known values are: "Succeeded", + "Updating", "Creating", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.SapVirtualInstanceProvisioningState - :ivar errors: Defines the Virtual Instance for SAP errors. + :ivar errors: Indicates any errors on the Virtual Instance for SAP solutions resource. :vartype errors: ~azure.mgmt.workloads.models.SAPVirtualInstanceError """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - '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 = { - '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'}, - 'environment': {'key': 'properties.environment', 'type': 'str'}, - 'sap_product': {'key': 'properties.sapProduct', 'type': 'str'}, - 'configuration': {'key': 'properties.configuration', 'type': 'SAPConfiguration'}, - 'managed_resource_group_configuration': {'key': 'properties.managedResourceGroupConfiguration', 'type': 'ManagedRGConfiguration'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'health': {'key': 'properties.health', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'errors': {'key': 'properties.errors', 'type': 'SAPVirtualInstanceError'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "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 = { + "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"}, + "environment": {"key": "properties.environment", "type": "str"}, + "sap_product": {"key": "properties.sapProduct", "type": "str"}, + "configuration": {"key": "properties.configuration", "type": "SAPConfiguration"}, + "managed_resource_group_configuration": { + "key": "properties.managedResourceGroupConfiguration", + "type": "ManagedRGConfiguration", + }, + "status": {"key": "properties.status", "type": "str"}, + "health": {"key": "properties.health", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "errors": {"key": "properties.errors", "type": "SAPVirtualInstanceError"}, } def __init__( self, *, location: str, - environment: Union[str, "SAPEnvironmentType"], - sap_product: Union[str, "SAPProductType"], - configuration: "SAPConfiguration", + environment: Union[str, "_models.SAPEnvironmentType"], + sap_product: Union[str, "_models.SAPProductType"], + configuration: "_models.SAPConfiguration", tags: Optional[Dict[str, str]] = None, - identity: Optional["UserAssignedServiceIdentity"] = None, - managed_resource_group_configuration: Optional["ManagedRGConfiguration"] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, + managed_resource_group_configuration: Optional["_models.ManagedRGConfiguration"] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :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.workloads.models.UserAssignedServiceIdentity - :keyword environment: Required. Defines the environment type - Production/Non Production. - Possible values include: "NonProd", "Prod". + :keyword environment: Defines the environment type - Production/Non Production. Required. Known + values are: "NonProd" and "Prod". :paramtype environment: str or ~azure.mgmt.workloads.models.SAPEnvironmentType - :keyword sap_product: Required. Defines the SAP Product type. Possible values include: "ECC", - "S4HANA", "Other". + :keyword sap_product: Defines the SAP Product type. Required. Known values are: "ECC", + "S4HANA", and "Other". :paramtype sap_product: str or ~azure.mgmt.workloads.models.SAPProductType - :keyword configuration: Required. Defines if an existing SAP system is being registered or a - new SAP system is being created. + :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.workloads.models.SAPConfiguration :keyword managed_resource_group_configuration: Managed resource group configuration. :paramtype managed_resource_group_configuration: ~azure.mgmt.workloads.models.ManagedRGConfiguration """ - super(SAPVirtualInstance, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.identity = identity self.environment = environment self.sap_product = sap_product @@ -4996,7 +4838,7 @@ def __init__( self.errors = None -class SAPVirtualInstanceError(msrest.serialization.Model): +class SAPVirtualInstanceError(_serialization.Model): """An error response from the Virtual Instance for SAP Workload service. :ivar properties: The Virtual Instance for SAP error body. @@ -5004,51 +4846,42 @@ class SAPVirtualInstanceError(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'ErrorDefinition'}, + "properties": {"key": "properties", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - properties: Optional["ErrorDefinition"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ErrorDefinition"] = None, **kwargs): """ :keyword properties: The Virtual Instance for SAP error body. :paramtype properties: ~azure.mgmt.workloads.models.ErrorDefinition """ - super(SAPVirtualInstanceError, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SAPVirtualInstanceList(msrest.serialization.Model): - """Defines the collection of Virtual Instance for SAP. +class SAPVirtualInstanceList(_serialization.Model): + """Defines the collection of Virtual Instance for SAP solutions resources. - :ivar value: Gets the list of Virtual Instances for SAP. + :ivar value: Gets the list of Virtual Instances for SAP solutions resources. :vartype value: list[~azure.mgmt.workloads.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'}, + "value": {"key": "value", "type": "[SAPVirtualInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["SAPVirtualInstance"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SAPVirtualInstance"]] = None, next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Gets the list of Virtual Instances for SAP. + :keyword value: Gets the list of Virtual Instances for SAP solutions resources. :paramtype value: list[~azure.mgmt.workloads.models.SAPVirtualInstance] :keyword next_link: Gets the value of next link. :paramtype next_link: str """ - super(SAPVirtualInstanceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -5062,64 +4895,66 @@ class SearchProfile(NodeProfile): :ivar name: VM or VMSS name. :vartype name: str - :ivar node_sku: Required. VM SKU for node(s). + :ivar node_sku: VM SKU for node(s). Required. :vartype node_sku: str - :ivar os_image: Required. OS image used for creating the nodes. + :ivar os_image: OS image used for creating the nodes. Required. :vartype os_image: ~azure.mgmt.workloads.models.OsImageProfile - :ivar os_disk: Required. OS disk details. + :ivar os_disk: OS disk details. Required. :vartype os_disk: ~azure.mgmt.workloads.models.DiskInfo :ivar data_disks: Data disks details. This property is not in use right now. :vartype data_disks: list[~azure.mgmt.workloads.models.DiskInfo] :ivar node_resource_ids: VM/VMSS resource ARM Ids. :vartype node_resource_ids: list[str] - :ivar search_type: Required. Search type. Possible values include: "Elastic". + :ivar search_type: Search type. Required. "Elastic" :vartype search_type: str or ~azure.mgmt.workloads.models.SearchType """ _validation = { - 'node_sku': {'required': True}, - 'os_image': {'required': True}, - 'os_disk': {'required': True}, - 'node_resource_ids': {'readonly': True}, - 'search_type': {'required': True}, + "node_sku": {"required": True}, + "os_image": {"required": True}, + "os_disk": {"required": True}, + "node_resource_ids": {"readonly": True}, + "search_type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'node_sku': {'key': 'nodeSku', 'type': 'str'}, - 'os_image': {'key': 'osImage', 'type': 'OsImageProfile'}, - 'os_disk': {'key': 'osDisk', 'type': 'DiskInfo'}, - 'data_disks': {'key': 'dataDisks', 'type': '[DiskInfo]'}, - 'node_resource_ids': {'key': 'nodeResourceIds', 'type': '[str]'}, - 'search_type': {'key': 'searchType', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "node_sku": {"key": "nodeSku", "type": "str"}, + "os_image": {"key": "osImage", "type": "OsImageProfile"}, + "os_disk": {"key": "osDisk", "type": "DiskInfo"}, + "data_disks": {"key": "dataDisks", "type": "[DiskInfo]"}, + "node_resource_ids": {"key": "nodeResourceIds", "type": "[str]"}, + "search_type": {"key": "searchType", "type": "str"}, } def __init__( self, *, node_sku: str, - os_image: "OsImageProfile", - os_disk: "DiskInfo", - search_type: Union[str, "SearchType"], + os_image: "_models.OsImageProfile", + os_disk: "_models.DiskInfo", + search_type: Union[str, "_models.SearchType"], name: Optional[str] = None, - data_disks: Optional[List["DiskInfo"]] = None, + data_disks: Optional[List["_models.DiskInfo"]] = None, **kwargs ): """ :keyword name: VM or VMSS name. :paramtype name: str - :keyword node_sku: Required. VM SKU for node(s). + :keyword node_sku: VM SKU for node(s). Required. :paramtype node_sku: str - :keyword os_image: Required. OS image used for creating the nodes. + :keyword os_image: OS image used for creating the nodes. Required. :paramtype os_image: ~azure.mgmt.workloads.models.OsImageProfile - :keyword os_disk: Required. OS disk details. + :keyword os_disk: OS disk details. Required. :paramtype os_disk: ~azure.mgmt.workloads.models.DiskInfo :keyword data_disks: Data disks details. This property is not in use right now. :paramtype data_disks: list[~azure.mgmt.workloads.models.DiskInfo] - :keyword search_type: Required. Search type. Possible values include: "Elastic". + :keyword search_type: Search type. Required. "Elastic" :paramtype search_type: str or ~azure.mgmt.workloads.models.SearchType """ - super(SearchProfile, self).__init__(name=name, node_sku=node_sku, os_image=os_image, os_disk=os_disk, data_disks=data_disks, **kwargs) + super().__init__( + name=name, node_sku=node_sku, os_image=os_image, os_disk=os_disk, data_disks=data_disks, **kwargs + ) self.search_type = search_type @@ -5128,19 +4963,19 @@ class ServiceInitiatedSoftwareConfiguration(SoftwareConfiguration): All required parameters must be populated in order to send to Azure. - :ivar software_installation_type: Required. The SAP software installation Type.Constant filled - by server. Possible values include: "ServiceInitiated", "SAPInstallWithoutOSConfig". + :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.workloads.models.SAPSoftwareInstallationType - :ivar bom_url: Required. The URL to the SAP Build of Materials(BOM) file. + :ivar bom_url: The URL to the SAP Build of Materials(BOM) file. Required. :vartype bom_url: str - :ivar software_version: Required. The software version to install. + :ivar software_version: The software version to install. Required. :vartype software_version: str - :ivar sap_bits_storage_account_id: Required. The SAP bits storage account id. + :ivar sap_bits_storage_account_id: The SAP bits storage account id. Required. :vartype sap_bits_storage_account_id: str - :ivar sap_fqdn: Required. The FQDN to set for the SAP system during install. + :ivar sap_fqdn: The FQDN to set for the SAP system during install. Required. :vartype sap_fqdn: str - :ivar ssh_private_key: Required. The SSH private key. + :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: @@ -5148,22 +4983,25 @@ class ServiceInitiatedSoftwareConfiguration(SoftwareConfiguration): """ _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}, + "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'}, + "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__( @@ -5174,26 +5012,26 @@ def __init__( sap_bits_storage_account_id: str, sap_fqdn: str, ssh_private_key: str, - high_availability_software_configuration: Optional["HighAvailabilitySoftwareConfiguration"] = None, + high_availability_software_configuration: Optional["_models.HighAvailabilitySoftwareConfiguration"] = None, **kwargs ): """ - :keyword bom_url: Required. The URL to the SAP Build of Materials(BOM) file. + :keyword bom_url: The URL to the SAP Build of Materials(BOM) file. Required. :paramtype bom_url: str - :keyword software_version: Required. The software version to install. + :keyword software_version: The software version to install. Required. :paramtype software_version: str - :keyword sap_bits_storage_account_id: Required. The SAP bits storage account id. + :keyword sap_bits_storage_account_id: The SAP bits storage account id. Required. :paramtype sap_bits_storage_account_id: str - :keyword sap_fqdn: Required. The FQDN to set for the SAP system during install. + :keyword sap_fqdn: The FQDN to set for the SAP system during install. Required. :paramtype sap_fqdn: str - :keyword ssh_private_key: Required. The SSH private key. + :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.workloads.models.HighAvailabilitySoftwareConfiguration """ - super(ServiceInitiatedSoftwareConfiguration, self).__init__(**kwargs) - self.software_installation_type = 'ServiceInitiated' # type: str + super().__init__(**kwargs) + self.software_installation_type = "ServiceInitiated" # type: str self.bom_url = bom_url self.software_version = software_version self.sap_bits_storage_account_id = sap_bits_storage_account_id @@ -5207,37 +5045,37 @@ class SingleServerConfiguration(InfrastructureConfiguration): All required parameters must be populated in order to send to Azure. - :ivar deployment_type: Required. The deployment Type.Constant filled by server. Possible values - include: "SingleServer", "ThreeTier". + :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.workloads.models.SAPDeploymentType - :ivar app_resource_group: Required. The application resource group where SAP system resources - will be deployed. + :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.workloads.models.NetworkConfiguration - :ivar database_type: The database type. Possible values include: "HANA", "DB2". + :ivar database_type: The database type. Known values are: "HANA" and "DB2". :vartype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :ivar subnet_id: Required. The subnet id. + :ivar subnet_id: The subnet id. Required. :vartype subnet_id: str - :ivar virtual_machine_configuration: Required. Gets or sets the virtual machine configuration. + :ivar virtual_machine_configuration: Gets or sets the virtual machine configuration. Required. :vartype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration """ _validation = { - 'deployment_type': {'required': True}, - 'app_resource_group': {'required': True}, - 'subnet_id': {'required': True}, - 'virtual_machine_configuration': {'required': True}, + "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'}, + "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"}, } def __init__( @@ -5245,28 +5083,28 @@ def __init__( *, app_resource_group: str, subnet_id: str, - virtual_machine_configuration: "VirtualMachineConfiguration", - network_configuration: Optional["NetworkConfiguration"] = None, - database_type: Optional[Union[str, "SAPDatabaseType"]] = None, + virtual_machine_configuration: "_models.VirtualMachineConfiguration", + network_configuration: Optional["_models.NetworkConfiguration"] = None, + database_type: Optional[Union[str, "_models.SAPDatabaseType"]] = None, **kwargs ): """ - :keyword app_resource_group: Required. The application resource group where SAP system - resources will be deployed. + :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.workloads.models.NetworkConfiguration - :keyword database_type: The database type. Possible values include: "HANA", "DB2". + :keyword database_type: The database type. Known values are: "HANA" and "DB2". :paramtype database_type: str or ~azure.mgmt.workloads.models.SAPDatabaseType - :keyword subnet_id: Required. The subnet id. + :keyword subnet_id: The subnet id. Required. :paramtype subnet_id: str - :keyword virtual_machine_configuration: Required. Gets or sets the virtual machine - configuration. + :keyword virtual_machine_configuration: Gets or sets the virtual machine configuration. + Required. :paramtype virtual_machine_configuration: ~azure.mgmt.workloads.models.VirtualMachineConfiguration """ - super(SingleServerConfiguration, self).__init__(app_resource_group=app_resource_group, **kwargs) - self.deployment_type = 'SingleServer' # type: str + super().__init__(app_resource_group=app_resource_group, **kwargs) + self.deployment_type = "SingleServer" # type: str self.network_configuration = network_configuration self.database_type = database_type self.subnet_id = subnet_id @@ -5278,38 +5116,33 @@ class SingleServerRecommendationResult(SAPSizingRecommendationResult): All required parameters must be populated in order to send to Azure. - :ivar deployment_type: Required. The deployment Type.Constant filled by server. Possible values - include: "SingleServer", "ThreeTier". + :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.workloads.models.SAPDeploymentType :ivar vm_sku: The recommended VM SKU for single server. :vartype vm_sku: str """ _validation = { - 'deployment_type': {'required': True}, + "deployment_type": {"required": True}, } _attribute_map = { - 'deployment_type': {'key': 'deploymentType', 'type': 'str'}, - 'vm_sku': {'key': 'vmSku', 'type': 'str'}, + "deployment_type": {"key": "deploymentType", "type": "str"}, + "vm_sku": {"key": "vmSku", "type": "str"}, } - def __init__( - self, - *, - vm_sku: Optional[str] = None, - **kwargs - ): + def __init__(self, *, vm_sku: Optional[str] = None, **kwargs): """ :keyword vm_sku: The recommended VM SKU for single server. :paramtype vm_sku: str """ - super(SingleServerRecommendationResult, self).__init__(**kwargs) - self.deployment_type = 'SingleServer' # type: str + super().__init__(**kwargs) + self.deployment_type = "SingleServer" # type: str self.vm_sku = vm_sku -class SiteProfile(msrest.serialization.Model): +class SiteProfile(_serialization.Model): """Workload website profile. :ivar domain_name: Domain name for the application site URL. @@ -5317,33 +5150,28 @@ class SiteProfile(msrest.serialization.Model): """ _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, } - def __init__( - self, - *, - domain_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, domain_name: Optional[str] = None, **kwargs): """ :keyword domain_name: Domain name for the application site URL. :paramtype domain_name: str """ - super(SiteProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The resource model definition representing SKU. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. + :ivar name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. :vartype name: str :ivar tier: This field is required to be implemented by the Resource Provider if the service - has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", - "Standard", "Premium". + has more than one tier, but is not required on a PUT. Known values are: "Free", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.workloads.models.SkuTier :ivar size: The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. @@ -5357,33 +5185,33 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( self, *, name: str, - tier: Optional[Union[str, "SkuTier"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, size: Optional[str] = None, family: Optional[str] = None, capacity: Optional[int] = None, **kwargs ): """ - :keyword name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. + :keyword name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. :paramtype name: str :keyword tier: This field is required to be implemented by the Resource Provider if the service - has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", - "Standard", "Premium". + has more than one tier, but is not required on a PUT. Known values are: "Free", "Basic", + "Standard", and "Premium". :paramtype tier: str or ~azure.mgmt.workloads.models.SkuTier :keyword size: The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. @@ -5395,7 +5223,7 @@ def __init__( included. If scale out/in is not possible for the resource this may be omitted. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -5403,7 +5231,7 @@ def __init__( self.capacity = capacity -class SkuCapability(msrest.serialization.Model): +class SkuCapability(_serialization.Model): """The SKU capability definition. :ivar name: The capability name. @@ -5413,29 +5241,23 @@ class SkuCapability(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs): """ :keyword name: The capability name. :paramtype name: str :keyword value: The capability value. :paramtype value: str """ - super(SkuCapability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """The SKU capacity. :ivar minimum: Minimum capacity value. @@ -5444,16 +5266,16 @@ class SkuCapacity(msrest.serialization.Model): :vartype maximum: int :ivar default: Default capacity value. :vartype default: int - :ivar scale_type: Scale type of the SKU capacity. Possible values include: "None", "Manual", + :ivar scale_type: Scale type of the SKU capacity. Known values are: "None", "Manual", and "Automatic". :vartype scale_type: str or ~azure.mgmt.workloads.models.SkuScaleType """ _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } def __init__( @@ -5462,7 +5284,7 @@ def __init__( minimum: Optional[int] = None, maximum: Optional[int] = None, default: Optional[int] = None, - scale_type: Optional[Union[str, "SkuScaleType"]] = None, + scale_type: Optional[Union[str, "_models.SkuScaleType"]] = None, **kwargs ): """ @@ -5472,18 +5294,18 @@ def __init__( :paramtype maximum: int :keyword default: Default capacity value. :paramtype default: int - :keyword scale_type: Scale type of the SKU capacity. Possible values include: "None", "Manual", + :keyword scale_type: Scale type of the SKU capacity. Known values are: "None", "Manual", and "Automatic". :paramtype scale_type: str or ~azure.mgmt.workloads.models.SkuScaleType """ - super(SkuCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default self.scale_type = scale_type -class SkuCost(msrest.serialization.Model): +class SkuCost(_serialization.Model): """The SKU cost definition. :ivar meter_id: Billing meter id. @@ -5495,9 +5317,9 @@ class SkuCost(msrest.serialization.Model): """ _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } def __init__( @@ -5516,18 +5338,18 @@ def __init__( :keyword extended_unit: The extended unit. :paramtype extended_unit: str """ - super(SkuCost, self).__init__(**kwargs) + super().__init__(**kwargs) self.meter_id = meter_id self.quantity = quantity self.extended_unit = extended_unit -class SkuDefinition(msrest.serialization.Model): +class SkuDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """The SKU definition. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. + :ivar name: The name of the SKU. Required. :vartype name: str :ivar resource_type: Resource type the SKU applicable for. :vartype resource_type: str @@ -5549,7 +5371,7 @@ class SkuDefinition(msrest.serialization.Model): :vartype location_info: list[~azure.mgmt.workloads.models.SkuLocationAndZones] :ivar capacity: If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. - :vartype capacity: any + :vartype capacity: JSON :ivar costs: The SKU costs. :vartype costs: list[~azure.mgmt.workloads.models.SkuCost] :ivar capabilities: The SKU capabilities. @@ -5559,22 +5381,22 @@ class SkuDefinition(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationAndZones]'}, - 'capacity': {'key': 'capacity', 'type': 'object'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SkuCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, + "name": {"key": "name", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationAndZones]"}, + "capacity": {"key": "capacity", "type": "object"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "capabilities": {"key": "capabilities", "type": "[SkuCapability]"}, + "restrictions": {"key": "restrictions", "type": "[SkuRestriction]"}, } def __init__( @@ -5587,15 +5409,15 @@ def __init__( family: Optional[str] = None, kind: Optional[str] = None, locations: Optional[List[str]] = None, - location_info: Optional[List["SkuLocationAndZones"]] = None, - capacity: Optional[Any] = None, - costs: Optional[List["SkuCost"]] = None, - capabilities: Optional[List["SkuCapability"]] = None, - restrictions: Optional[List["SkuRestriction"]] = None, + location_info: Optional[List["_models.SkuLocationAndZones"]] = None, + capacity: Optional[JSON] = None, + costs: Optional[List["_models.SkuCost"]] = None, + capabilities: Optional[List["_models.SkuCapability"]] = None, + restrictions: Optional[List["_models.SkuRestriction"]] = None, **kwargs ): """ - :keyword name: Required. The name of the SKU. + :keyword name: The name of the SKU. Required. :paramtype name: str :keyword resource_type: Resource type the SKU applicable for. :paramtype resource_type: str @@ -5617,7 +5439,7 @@ def __init__( :paramtype location_info: list[~azure.mgmt.workloads.models.SkuLocationAndZones] :keyword capacity: If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. - :paramtype capacity: any + :paramtype capacity: JSON :keyword costs: The SKU costs. :paramtype costs: list[~azure.mgmt.workloads.models.SkuCost] :keyword capabilities: The SKU capabilities. @@ -5625,7 +5447,7 @@ def __init__( :keyword restrictions: The SKU restrictions. :paramtype restrictions: list[~azure.mgmt.workloads.models.SkuRestriction] """ - super(SkuDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_type = resource_type self.tier = tier @@ -5640,7 +5462,7 @@ def __init__( self.restrictions = restrictions -class SkuLocationAndZones(msrest.serialization.Model): +class SkuLocationAndZones(_serialization.Model): """The SKU location and zone. :ivar location: The location of the SKU. @@ -5651,16 +5473,16 @@ class SkuLocationAndZones(msrest.serialization.Model): :vartype zone_details: list[~azure.mgmt.workloads.models.SkuZoneDetail] :ivar extended_locations: The extended locations of SKU. :vartype extended_locations: list[str] - :ivar type: Type of the extended location. Possible values include: "Region", "EdgeZone". + :ivar type: Type of the extended location. Known values are: "Region" and "EdgeZone". :vartype type: str or ~azure.mgmt.workloads.models.LocationType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[SkuZoneDetail]'}, - 'extended_locations': {'key': 'extendedLocations', 'type': '[str]'}, - 'type': {'key': 'type', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[SkuZoneDetail]"}, + "extended_locations": {"key": "extendedLocations", "type": "[str]"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -5668,9 +5490,9 @@ def __init__( *, location: Optional[str] = None, zones: Optional[List[str]] = None, - zone_details: Optional[List["SkuZoneDetail"]] = None, + zone_details: Optional[List["_models.SkuZoneDetail"]] = None, extended_locations: Optional[List[str]] = None, - type: Optional[Union[str, "LocationType"]] = None, + type: Optional[Union[str, "_models.LocationType"]] = None, **kwargs ): """ @@ -5682,10 +5504,10 @@ def __init__( :paramtype zone_details: list[~azure.mgmt.workloads.models.SkuZoneDetail] :keyword extended_locations: The extended locations of SKU. :paramtype extended_locations: list[str] - :keyword type: Type of the extended location. Possible values include: "Region", "EdgeZone". + :keyword type: Type of the extended location. Known values are: "Region" and "EdgeZone". :paramtype type: str or ~azure.mgmt.workloads.models.LocationType """ - super(SkuLocationAndZones, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones self.zone_details = zone_details @@ -5693,57 +5515,56 @@ def __init__( self.type = type -class SkuRestriction(msrest.serialization.Model): +class SkuRestriction(_serialization.Model): """The SKU restriction definition. - :ivar type: The SKU restriction type. Possible values include: "NotSpecified", "Location", - "Zone". + :ivar type: The SKU restriction type. Known values are: "NotSpecified", "Location", and "Zone". :vartype type: str or ~azure.mgmt.workloads.models.SkuRestrictionType :ivar values: Restriction values. :vartype values: list[str] :ivar restriction_info: The restriction information. - :vartype restriction_info: any - :ivar reason_code: The SKU restriction reason code. Possible values include: "NotSpecified", - "QuotaId", "NotAvailableForSubscription". + :vartype restriction_info: JSON + :ivar reason_code: The SKU restriction reason code. Known values are: "NotSpecified", + "QuotaId", and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.workloads.models.SkuRestrictionReasonCode """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'object'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "object"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "SkuRestrictionType"]] = None, + type: Optional[Union[str, "_models.SkuRestrictionType"]] = None, values: Optional[List[str]] = None, - restriction_info: Optional[Any] = None, - reason_code: Optional[Union[str, "SkuRestrictionReasonCode"]] = None, + restriction_info: Optional[JSON] = None, + reason_code: Optional[Union[str, "_models.SkuRestrictionReasonCode"]] = None, **kwargs ): """ - :keyword type: The SKU restriction type. Possible values include: "NotSpecified", "Location", + :keyword type: The SKU restriction type. Known values are: "NotSpecified", "Location", and "Zone". :paramtype type: str or ~azure.mgmt.workloads.models.SkuRestrictionType :keyword values: Restriction values. :paramtype values: list[str] :keyword restriction_info: The restriction information. - :paramtype restriction_info: any - :keyword reason_code: The SKU restriction reason code. Possible values include: "NotSpecified", - "QuotaId", "NotAvailableForSubscription". + :paramtype restriction_info: JSON + :keyword reason_code: The SKU restriction reason code. Known values are: "NotSpecified", + "QuotaId", and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.workloads.models.SkuRestrictionReasonCode """ - super(SkuRestriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.values = values self.restriction_info = restriction_info self.reason_code = reason_code -class SkusListResult(msrest.serialization.Model): +class SkusListResult(_serialization.Model): """A list of SKUs supported by an Azure Resource Provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -5755,27 +5576,23 @@ class SkusListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SkuDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkusListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuZoneDetail(msrest.serialization.Model): +class SkuZoneDetail(_serialization.Model): """The SKU zone details. :ivar zones: The physical zones. @@ -5785,15 +5602,15 @@ class SkuZoneDetail(msrest.serialization.Model): """ _attribute_map = { - 'zones': {'key': 'zones', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SkuCapability]'}, + "zones": {"key": "zones", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SkuCapability]"}, } def __init__( self, *, zones: Optional[List[str]] = None, - capabilities: Optional[List["SkuCapability"]] = None, + capabilities: Optional[List["_models.SkuCapability"]] = None, **kwargs ): """ @@ -5802,12 +5619,12 @@ def __init__( :keyword capabilities: The capabilities. :paramtype capabilities: list[~azure.mgmt.workloads.models.SkuCapability] """ - super(SkuZoneDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.zones = zones self.capabilities = capabilities -class SshConfiguration(msrest.serialization.Model): +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. @@ -5815,24 +5632,19 @@ class SshConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'public_keys': {'key': 'publicKeys', 'type': '[SshPublicKey]'}, + "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, } - def __init__( - self, - *, - public_keys: Optional[List["SshPublicKey"]] = None, - **kwargs - ): + def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs): """ :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. :paramtype public_keys: list[~azure.mgmt.workloads.models.SshPublicKey] """ - super(SshConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_keys = public_keys -class SshKeyPair(msrest.serialization.Model): +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. @@ -5842,29 +5654,23 @@ class SshKeyPair(msrest.serialization.Model): """ _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, + "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 - ): + def __init__(self, *, public_key: Optional[str] = None, private_key: Optional[str] = None, **kwargs): """ :keyword public_key: SSH public key. :paramtype public_key: str :keyword private_key: SSH private key. :paramtype private_key: str """ - super(SshKeyPair, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_key = public_key self.private_key = private_key -class SshPublicKey(msrest.serialization.Model): +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 @@ -5875,15 +5681,10 @@ class SshPublicKey(msrest.serialization.Model): """ _attribute_map = { - 'key_data': {'key': 'keyData', 'type': 'str'}, + "key_data": {"key": "keyData", "type": "str"}, } - def __init__( - self, - *, - key_data: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_data: Optional[str] = None, **kwargs): """ :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 @@ -5891,11 +5692,11 @@ def __init__( `_. :paramtype key_data: str """ - super(SshPublicKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_data = key_data -class StopRequest(msrest.serialization.Model): +class StopRequest(_serialization.Model): """Stop SAP Request. :ivar hard_stop: A boolean to specify if the SAP system should be hard-stopped. @@ -5903,79 +5704,74 @@ class StopRequest(msrest.serialization.Model): """ _attribute_map = { - 'hard_stop': {'key': 'hardStop', 'type': 'bool'}, + "hard_stop": {"key": "hardStop", "type": "bool"}, } - def __init__( - self, - *, - hard_stop: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, hard_stop: bool = False, **kwargs): """ :keyword hard_stop: A boolean to specify if the SAP system should be hard-stopped. :paramtype hard_stop: bool """ - super(StopRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.hard_stop = hard_stop -class SystemData(msrest.serialization.Model): +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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :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.workloads.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :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.workloads.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_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, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :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.workloads.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :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.workloads.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -5984,28 +5780,23 @@ def __init__( self.last_modified_at = last_modified_at -class Tags(msrest.serialization.Model): +class Tags(_serialization.Model): """Tags field of the resource. - :ivar tags: A set of tags. Tags field of the resource. + :ivar tags: Tags field of the resource. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Tags field of the resource. + :keyword tags: Tags field of the resource. :paramtype tags: dict[str, str] """ - super(Tags, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags @@ -6014,70 +5805,70 @@ class ThreeTierConfiguration(InfrastructureConfiguration): All required parameters must be populated in order to send to Azure. - :ivar deployment_type: Required. The deployment Type.Constant filled by server. Possible values - include: "SingleServer", "ThreeTier". + :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.workloads.models.SAPDeploymentType - :ivar app_resource_group: Required. The application resource group where SAP system resources - will be deployed. + :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.workloads.models.NetworkConfiguration - :ivar central_server: Required. The central server configuration. + :ivar central_server: The central server configuration. Required. :vartype central_server: ~azure.mgmt.workloads.models.CentralServerConfiguration - :ivar application_server: Required. The application server configuration. + :ivar application_server: The application server configuration. Required. :vartype application_server: ~azure.mgmt.workloads.models.ApplicationServerConfiguration - :ivar database_server: Required. The database configuration. + :ivar database_server: The database configuration. Required. :vartype database_server: ~azure.mgmt.workloads.models.DatabaseConfiguration :ivar high_availability_config: The high availability configuration. :vartype high_availability_config: ~azure.mgmt.workloads.models.HighAvailabilityConfiguration """ _validation = { - 'deployment_type': {'required': True}, - 'app_resource_group': {'required': True}, - 'central_server': {'required': True}, - 'application_server': {'required': True}, - 'database_server': {'required': True}, + "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'}, + "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"}, } def __init__( self, *, app_resource_group: str, - central_server: "CentralServerConfiguration", - application_server: "ApplicationServerConfiguration", - database_server: "DatabaseConfiguration", - network_configuration: Optional["NetworkConfiguration"] = None, - high_availability_config: Optional["HighAvailabilityConfiguration"] = None, + 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, **kwargs ): """ - :keyword app_resource_group: Required. The application resource group where SAP system - resources will be deployed. + :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.workloads.models.NetworkConfiguration - :keyword central_server: Required. The central server configuration. + :keyword central_server: The central server configuration. Required. :paramtype central_server: ~azure.mgmt.workloads.models.CentralServerConfiguration - :keyword application_server: Required. The application server configuration. + :keyword application_server: The application server configuration. Required. :paramtype application_server: ~azure.mgmt.workloads.models.ApplicationServerConfiguration - :keyword database_server: Required. The database configuration. + :keyword database_server: The database configuration. Required. :paramtype database_server: ~azure.mgmt.workloads.models.DatabaseConfiguration :keyword high_availability_config: The high availability configuration. :paramtype high_availability_config: ~azure.mgmt.workloads.models.HighAvailabilityConfiguration """ - super(ThreeTierConfiguration, self).__init__(app_resource_group=app_resource_group, **kwargs) - self.deployment_type = 'ThreeTier' # type: str + super().__init__(app_resource_group=app_resource_group, **kwargs) + self.deployment_type = "ThreeTier" # type: str self.network_configuration = network_configuration self.central_server = central_server self.application_server = application_server @@ -6090,35 +5881,35 @@ class ThreeTierRecommendationResult(SAPSizingRecommendationResult): All required parameters must be populated in order to send to Azure. - :ivar deployment_type: Required. The deployment Type.Constant filled by server. Possible values - include: "SingleServer", "ThreeTier". + :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.workloads.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: long + :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: long + :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: long + :vartype application_server_instance_count: int """ _validation = { - 'deployment_type': {'required': True}, + "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': 'long'}, - 'central_server_vm_sku': {'key': 'centralServerVmSku', 'type': 'str'}, - 'central_server_instance_count': {'key': 'centralServerInstanceCount', 'type': 'long'}, - 'application_server_vm_sku': {'key': 'applicationServerVmSku', 'type': 'str'}, - 'application_server_instance_count': {'key': 'applicationServerInstanceCount', 'type': 'long'}, + "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__( @@ -6136,18 +5927,18 @@ def __init__( :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: long + :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: long + :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: long + :paramtype application_server_instance_count: int """ - super(ThreeTierRecommendationResult, self).__init__(**kwargs) - self.deployment_type = 'ThreeTier' # type: str + super().__init__(**kwargs) + self.deployment_type = "ThreeTier" # type: str self.db_vm_sku = db_vm_sku self.database_instance_count = database_instance_count self.central_server_vm_sku = central_server_vm_sku @@ -6156,146 +5947,131 @@ def __init__( self.application_server_instance_count = application_server_instance_count -class UpdateMonitorRequest(msrest.serialization.Model): +class UpdateMonitorRequest(_serialization.Model): """Defines the request body for updating SAP monitor resource. - :ivar tags: A set of tags. Gets or sets the Resource tags. + :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.workloads.models.UserAssignedServiceIdentity """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedServiceIdentity'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "UserAssignedServiceIdentity"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["UserAssignedServiceIdentity"] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, **kwargs ): """ - :keyword tags: A set of tags. Gets or sets the Resource tags. + :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.workloads.models.UserAssignedServiceIdentity """ - super(UpdateMonitorRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity -class UpdateSAPApplicationInstanceRequest(msrest.serialization.Model): +class UpdateSAPApplicationInstanceRequest(_serialization.Model): """Defines the request body for updating SAP Application Instance. - :ivar tags: A set of tags. Gets or sets the Resource tags. + :ivar tags: Gets or sets the Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Gets or sets the Resource tags. + :keyword tags: Gets or sets the Resource tags. :paramtype tags: dict[str, str] """ - super(UpdateSAPApplicationInstanceRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class UpdateSAPCentralInstanceRequest(msrest.serialization.Model): +class UpdateSAPCentralInstanceRequest(_serialization.Model): """Defines the request body for updating SAP Central Instance. - :ivar tags: A set of tags. Gets or sets the Resource tags. + :ivar tags: Gets or sets the Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Gets or sets the Resource tags. + :keyword tags: Gets or sets the Resource tags. :paramtype tags: dict[str, str] """ - super(UpdateSAPCentralInstanceRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class UpdateSAPDatabaseInstanceRequest(msrest.serialization.Model): +class UpdateSAPDatabaseInstanceRequest(_serialization.Model): """Defines the request body for updating SAP Database Instance. - :ivar tags: A set of tags. Gets or sets the Resource tags. + :ivar tags: Gets or sets the Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Gets or sets the Resource tags. + :keyword tags: Gets or sets the Resource tags. :paramtype tags: dict[str, str] """ - super(UpdateSAPDatabaseInstanceRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class UpdateSAPVirtualInstanceRequest(msrest.serialization.Model): +class UpdateSAPVirtualInstanceRequest(_serialization.Model): """Defines the request body for updating Virtual Instance for SAP. - :ivar tags: A set of tags. Gets or sets the Resource tags. + :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.workloads.models.UserAssignedServiceIdentity """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedServiceIdentity'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "UserAssignedServiceIdentity"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["UserAssignedServiceIdentity"] = None, + identity: Optional["_models.UserAssignedServiceIdentity"] = None, **kwargs ): """ - :keyword tags: A set of tags. Gets or sets the Resource tags. + :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.workloads.models.UserAssignedServiceIdentity """ - super(UpdateSAPVirtualInstanceRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """User assigned identity properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -6307,107 +6083,92 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserProfile(msrest.serialization.Model): +class UserProfile(_serialization.Model): """User profile to configure on a compute resources such as VM, VMSS. All required parameters must be populated in order to send to Azure. - :ivar user_name: Required. User name. + :ivar user_name: User name. Required. :vartype user_name: str - :ivar ssh_public_key: Required. SSH public key data. + :ivar ssh_public_key: SSH public key data. Required. :vartype ssh_public_key: str """ _validation = { - 'user_name': {'required': True}, - 'ssh_public_key': {'required': True}, + "user_name": {"required": True}, + "ssh_public_key": {"required": True}, } _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'ssh_public_key': {'key': 'sshPublicKey', 'type': 'str'}, + "user_name": {"key": "userName", "type": "str"}, + "ssh_public_key": {"key": "sshPublicKey", "type": "str"}, } - def __init__( - self, - *, - user_name: str, - ssh_public_key: str, - **kwargs - ): + def __init__(self, *, user_name: str, ssh_public_key: str, **kwargs): """ - :keyword user_name: Required. User name. + :keyword user_name: User name. Required. :paramtype user_name: str - :keyword ssh_public_key: Required. SSH public key data. + :keyword ssh_public_key: SSH public key data. Required. :paramtype ssh_public_key: str """ - super(UserProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_name = user_name self.ssh_public_key = ssh_public_key -class VirtualMachineConfiguration(msrest.serialization.Model): +class VirtualMachineConfiguration(_serialization.Model): """Defines the virtual machine configuration. All required parameters must be populated in order to send to Azure. - :ivar vm_size: Required. The virtual machine size. + :ivar vm_size: The virtual machine size. Required. :vartype vm_size: str - :ivar image_reference: Required. The image reference. + :ivar image_reference: The image reference. Required. :vartype image_reference: ~azure.mgmt.workloads.models.ImageReference - :ivar os_profile: Required. The OS profile. + :ivar os_profile: The OS profile. Required. :vartype os_profile: ~azure.mgmt.workloads.models.OSProfile """ _validation = { - 'vm_size': {'required': True}, - 'image_reference': {'required': True}, - 'os_profile': {'required': True}, + "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'}, + "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: "ImageReference", - os_profile: "OSProfile", - **kwargs + self, *, vm_size: str, image_reference: "_models.ImageReference", os_profile: "_models.OSProfile", **kwargs ): """ - :keyword vm_size: Required. The virtual machine size. + :keyword vm_size: The virtual machine size. Required. :paramtype vm_size: str - :keyword image_reference: Required. The image reference. + :keyword image_reference: The image reference. Required. :paramtype image_reference: ~azure.mgmt.workloads.models.ImageReference - :keyword os_profile: Required. The OS profile. + :keyword os_profile: The OS profile. Required. :paramtype os_profile: ~azure.mgmt.workloads.models.OSProfile """ - super(VirtualMachineConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.vm_size = vm_size self.image_reference = image_reference self.os_profile = os_profile @@ -6422,11 +6183,11 @@ class VmssNodesProfile(NodeProfile): :ivar name: VM or VMSS name. :vartype name: str - :ivar node_sku: Required. VM SKU for node(s). + :ivar node_sku: VM SKU for node(s). Required. :vartype node_sku: str - :ivar os_image: Required. OS image used for creating the nodes. + :ivar os_image: OS image used for creating the nodes. Required. :vartype os_image: ~azure.mgmt.workloads.models.OsImageProfile - :ivar os_disk: Required. OS disk details. + :ivar os_disk: OS disk details. Required. :vartype os_disk: ~azure.mgmt.workloads.models.DiskInfo :ivar data_disks: Data disks details. This property is not in use right now. :vartype data_disks: list[~azure.mgmt.workloads.models.DiskInfo] @@ -6439,33 +6200,33 @@ class VmssNodesProfile(NodeProfile): """ _validation = { - 'node_sku': {'required': True}, - 'os_image': {'required': True}, - 'os_disk': {'required': True}, - 'node_resource_ids': {'readonly': True}, - 'auto_scale_min_count': {'minimum': 1}, - 'auto_scale_max_count': {'minimum': 1}, + "node_sku": {"required": True}, + "os_image": {"required": True}, + "os_disk": {"required": True}, + "node_resource_ids": {"readonly": True}, + "auto_scale_min_count": {"minimum": 1}, + "auto_scale_max_count": {"minimum": 1}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'node_sku': {'key': 'nodeSku', 'type': 'str'}, - 'os_image': {'key': 'osImage', 'type': 'OsImageProfile'}, - 'os_disk': {'key': 'osDisk', 'type': 'DiskInfo'}, - 'data_disks': {'key': 'dataDisks', 'type': '[DiskInfo]'}, - 'node_resource_ids': {'key': 'nodeResourceIds', 'type': '[str]'}, - 'auto_scale_min_count': {'key': 'autoScaleMinCount', 'type': 'int'}, - 'auto_scale_max_count': {'key': 'autoScaleMaxCount', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "node_sku": {"key": "nodeSku", "type": "str"}, + "os_image": {"key": "osImage", "type": "OsImageProfile"}, + "os_disk": {"key": "osDisk", "type": "DiskInfo"}, + "data_disks": {"key": "dataDisks", "type": "[DiskInfo]"}, + "node_resource_ids": {"key": "nodeResourceIds", "type": "[str]"}, + "auto_scale_min_count": {"key": "autoScaleMinCount", "type": "int"}, + "auto_scale_max_count": {"key": "autoScaleMaxCount", "type": "int"}, } def __init__( self, *, node_sku: str, - os_image: "OsImageProfile", - os_disk: "DiskInfo", + os_image: "_models.OsImageProfile", + os_disk: "_models.DiskInfo", name: Optional[str] = None, - data_disks: Optional[List["DiskInfo"]] = None, + data_disks: Optional[List["_models.DiskInfo"]] = None, auto_scale_min_count: Optional[int] = None, auto_scale_max_count: Optional[int] = None, **kwargs @@ -6473,11 +6234,11 @@ def __init__( """ :keyword name: VM or VMSS name. :paramtype name: str - :keyword node_sku: Required. VM SKU for node(s). + :keyword node_sku: VM SKU for node(s). Required. :paramtype node_sku: str - :keyword os_image: Required. OS image used for creating the nodes. + :keyword os_image: OS image used for creating the nodes. Required. :paramtype os_image: ~azure.mgmt.workloads.models.OsImageProfile - :keyword os_disk: Required. OS disk details. + :keyword os_disk: OS disk details. Required. :paramtype os_disk: ~azure.mgmt.workloads.models.DiskInfo :keyword data_disks: Data disks details. This property is not in use right now. :paramtype data_disks: list[~azure.mgmt.workloads.models.DiskInfo] @@ -6486,7 +6247,9 @@ def __init__( :keyword auto_scale_max_count: Maximum number of nodes for autoscale. :paramtype auto_scale_max_count: int """ - super(VmssNodesProfile, self).__init__(name=name, node_sku=node_sku, os_image=os_image, os_disk=os_disk, data_disks=data_disks, **kwargs) + super().__init__( + name=name, node_sku=node_sku, os_image=os_image, os_disk=os_disk, data_disks=data_disks, **kwargs + ) self.auto_scale_min_count = auto_scale_min_count self.auto_scale_max_count = auto_scale_max_count @@ -6496,27 +6259,22 @@ class WindowsConfiguration(OSConfiguration): All required parameters must be populated in order to send to Azure. - :ivar os_type: Required. The OS Type.Constant filled by server. Possible values include: - "Linux", "Windows". + :ivar os_type: The OS Type. Required. Known values are: "Linux" and "Windows". :vartype os_type: str or ~azure.mgmt.workloads.models.OSType """ _validation = { - 'os_type': {'required': True}, + "os_type": {"required": True}, } _attribute_map = { - 'os_type': {'key': 'osType', 'type': 'str'}, + "os_type": {"key": "osType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(WindowsConfiguration, self).__init__(**kwargs) - self.os_type = 'Windows' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.os_type = "Windows" # type: str class WordpressInstanceResource(ProxyResource): @@ -6535,7 +6293,7 @@ class WordpressInstanceResource(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.workloads.models.SystemData - :ivar version: Application version. Possible values include: "5.4.3", "5.4.2", "5.4.1", "5.4". + :ivar version: Application version. Known values are: "5.4.3", "5.4.2", "5.4.1", and "5.4". :vartype version: str or ~azure.mgmt.workloads.models.WordpressVersions :ivar database_name: Database name used by the application. :vartype database_name: str @@ -6543,50 +6301,49 @@ class WordpressInstanceResource(ProxyResource): :vartype database_user: str :ivar site_url: Site Url to access the WordPress application. :vartype site_url: str - :ivar provisioning_state: WordPress instance provisioning state. Possible values include: - "NotSpecified", "Accepted", "Created", "Succeeded", "Failed", "Canceled", "Installing". + :ivar provisioning_state: WordPress instance provisioning state. Known values are: + "NotSpecified", "Accepted", "Created", "Succeeded", "Failed", "Canceled", and "Installing". :vartype provisioning_state: str or ~azure.mgmt.workloads.models.ApplicationProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'site_url': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "site_url": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'database_user': {'key': 'properties.databaseUser', 'type': 'str'}, - 'site_url': {'key': 'properties.siteUrl', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "version": {"key": "properties.version", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "database_user": {"key": "properties.databaseUser", "type": "str"}, + "site_url": {"key": "properties.siteUrl", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - version: Optional[Union[str, "WordpressVersions"]] = None, + version: Optional[Union[str, "_models.WordpressVersions"]] = None, database_name: Optional[str] = None, database_user: Optional[str] = None, **kwargs ): """ - :keyword version: Application version. Possible values include: "5.4.3", "5.4.2", "5.4.1", - "5.4". + :keyword version: Application version. Known values are: "5.4.3", "5.4.2", "5.4.1", and "5.4". :paramtype version: str or ~azure.mgmt.workloads.models.WordpressVersions :keyword database_name: Database name used by the application. :paramtype database_name: str :keyword database_user: User name used by the application to connect to database. :paramtype database_user: str """ - super(WordpressInstanceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = version self.database_name = database_name self.database_user = database_user @@ -6594,7 +6351,7 @@ def __init__( self.provisioning_state = None -class WordpressInstanceResourceList(msrest.serialization.Model): +class WordpressInstanceResourceList(_serialization.Model): """WordPress instance resource list. :ivar value: List of resources in current page. @@ -6604,14 +6361,14 @@ class WordpressInstanceResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[WordpressInstanceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WordpressInstanceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["WordpressInstanceResource"]] = None, + value: Optional[List["_models.WordpressInstanceResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -6621,6 +6378,6 @@ def __init__( :keyword next_link: Link to next page of resources. :paramtype next_link: str """ - super(WordpressInstanceResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/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-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py index d405fdf30ca0..387f6c991607 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/models/_workloads_client_enums.py @@ -7,19 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class ApplicationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """WordPress instance provisioning state - """ + +class ApplicationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WordPress instance provisioning state.""" NOT_SPECIFIED = "NotSpecified" ACCEPTED = "Accepted" @@ -29,16 +27,16 @@ class ApplicationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, CANCELED = "Canceled" INSTALLING = "Installing" -class AzureFrontDoorEnabled(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to enable Azure front door - """ + +class AzureFrontDoorEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to enable Azure front door.""" ENABLED = "Enabled" DISABLED = "Disabled" -class CentralServerVirtualMachineType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the type of central server VM. - """ + +class CentralServerVirtualMachineType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the type of central server VM.""" PRIMARY = "Primary" SECONDARY = "Secondary" @@ -48,162 +46,163 @@ class CentralServerVirtualMachineType(with_metaclass(CaseInsensitiveEnumMeta, st ERS = "ERS" STANDBY = "Standby" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DatabaseTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Tier of the server SKU - """ + +class DatabaseTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Tier of the server SKU.""" BURSTABLE = "Burstable" GENERAL_PURPOSE = "GeneralPurpose" MEMORY_OPTIMIZED = "MemoryOptimized" -class DatabaseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Database type - """ + +class DatabaseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Database type.""" MY_SQL = "MySql" -class DiskStorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Storage type - """ + +class DiskStorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage type.""" PREMIUM_LRS = "Premium_LRS" STANDARD_LRS = "Standard_LRS" STANDARD_SSD_LRS = "StandardSSD_LRS" -class EnableBackup(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to enable Azure backup for the workload - """ + +class EnableBackup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to enable Azure backup for the workload.""" ENABLED = "Enabled" DISABLED = "Disabled" -class EnableSslEnforcement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to enable SSL enforcement on the database - """ + +class EnableSslEnforcement(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to enable SSL enforcement on the database.""" ENABLED = "Enabled" DISABLED = "Disabled" -class EnqueueReplicationServerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the type of Enqueue Replication Server. - """ + +class EnqueueReplicationServerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the type of Enqueue Replication Server.""" ENQUEUE_REPLICATOR1 = "EnqueueReplicator1" ENQUEUE_REPLICATOR2 = "EnqueueReplicator2" -class FileShareStorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """File share backing storage type - """ + +class FileShareStorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """File share backing storage type.""" STANDARD_LRS = "Standard_LRS" STANDARD_GRS = "Standard_GRS" STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class FileShareType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Share type - """ + +class FileShareType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Share type.""" NFS_ON_CONTROLLER = "NfsOnController" AZURE_FILES = "AzureFiles" -class HAEnabled(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to enable HA for the server - """ + +class HAEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to enable HA for the server.""" ENABLED = "Enabled" DISABLED = "Disabled" -class LoadBalancerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Load balancer type - """ + +class LoadBalancerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Load balancer type.""" APPLICATION_GATEWAY = "ApplicationGateway" LOAD_BALANCER = "LoadBalancer" -class LocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the extended location. - """ + +class LocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the extended location.""" REGION = "Region" EDGE_ZONE = "EdgeZone" -class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of managed service identity (only None, UserAssigned types are allowed). - """ + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (only None, UserAssigned types are allowed).""" NONE = "None" USER_ASSIGNED = "UserAssigned" -class OperationProperties(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the workload operation origin. - """ + +class OperationProperties(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the workload operation origin.""" NOT_SPECIFIED = "NotSpecified" USER = "User" SYSTEM = "System" -class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +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" + logs UX. Default value is "user,system". """ USER = "user" SYSTEM = "system" USER_SYSTEM = "user,system" -class OSImageOffer(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """OS image offer - """ + +class OSImageOffer(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """OS image offer.""" UBUNTU_SERVER = "UbuntuServer" -class OSImagePublisher(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """OS image publisher - """ + +class OSImagePublisher(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """OS image publisher.""" CANONICAL = "Canonical" -class OSImageSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """OS image sku - """ + +class OSImageSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """OS image sku.""" EIGHTEEN04_LTS = "18.04-LTS" SIXTEEN04_LTS = "16.04-LTS" -class OSImageVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """OS image version - """ + +class OSImageVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """OS image version.""" LATEST = "latest" -class OSType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The OS Type - """ + +class OSType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The OS Type.""" LINUX = "Linux" WINDOWS = "Windows" -class PHPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """PHP version - """ + +class PHPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PHP version.""" SEVEN2 = "7.2" SEVEN3 = "7.3" SEVEN4 = "7.4" -class PhpWorkloadProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Php workload resource provisioning state - """ + +class PhpWorkloadProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Php workload resource provisioning state.""" NOT_SPECIFIED = "NotSpecified" ACCEPTED = "Accepted" @@ -214,14 +213,15 @@ class PhpWorkloadProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, PROVISIONING = "Provisioning" DELETING = "Deleting" -class RedisCacheFamily(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Cache family - """ + +class RedisCacheFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cache family.""" C = "C" P = "P" -class RoutingPreference(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingPreference(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sets the routing preference of the SAP monitor. By default only RFC1918 traffic is routed to the customer VNET. """ @@ -229,51 +229,52 @@ class RoutingPreference(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" ROUTE_ALL = "RouteAll" -class SAPConfigurationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The configuration Type. - """ + +class SAPConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The configuration Type.""" DEPLOYMENT = "Deployment" DISCOVERY = "Discovery" DEPLOYMENT_WITH_OS_CONFIG = "DeploymentWithOSConfig" -class SAPDatabaseScaleMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The database scale method. - """ + +class SAPDatabaseScaleMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The database scale method.""" SCALE_UP = "ScaleUp" -class SAPDatabaseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the supported SAP Database types. - """ + +class SAPDatabaseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the supported SAP Database types.""" HANA = "HANA" DB2 = "DB2" -class SAPDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The deployment Type. - """ + +class SAPDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of SAP deployment, single server or Three tier.""" SINGLE_SERVER = "SingleServer" THREE_TIER = "ThreeTier" -class SAPEnvironmentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the environment type - Production/Non Production. - """ + +class SAPEnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the environment type - Production/Non Production.""" NON_PROD = "NonProd" PROD = "Prod" -class SAPHealthState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the SAP Instance health. - """ + +class SAPHealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the health of SAP Instances.""" UNKNOWN = "Unknown" HEALTHY = "Healthy" UNHEALTHY = "Unhealthy" DEGRADED = "Degraded" -class SAPHighAvailabilityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SAPHighAvailabilityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The high availability Type. AvailabilitySet guarantees 99.95% availability. Availability Zone guarantees 99.99% availability. """ @@ -281,24 +282,25 @@ class SAPHighAvailabilityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AVAILABILITY_SET = "AvailabilitySet" AVAILABILITY_ZONE = "AvailabilityZone" -class SAPProductType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the SAP Product type. - """ + +class SAPProductType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the SAP Product type.""" ECC = "ECC" S4_HANA = "S4HANA" OTHER = "Other" -class SAPSoftwareInstallationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SAP software installation Type. - """ + +class SAPSoftwareInstallationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SAP software installation Type.""" SERVICE_INITIATED = "ServiceInitiated" SAP_INSTALL_WITHOUT_OS_CONFIG = "SAPInstallWithoutOSConfig" + EXTERNAL = "External" -class SapVirtualInstanceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the provisioning states. - """ + +class SapVirtualInstanceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the provisioning states.""" SUCCEEDED = "Succeeded" UPDATING = "Updating" @@ -306,9 +308,9 @@ class SapVirtualInstanceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta FAILED = "Failed" DELETING = "Deleting" -class SAPVirtualInstanceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the Virtual Instance for SAP state. - """ + +class SAPVirtualInstanceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the Virtual Instance for SAP state.""" INFRASTRUCTURE_DEPLOYMENT_PENDING = "InfrastructureDeploymentPending" INFRASTRUCTURE_DEPLOYMENT_IN_PROGRESS = "InfrastructureDeploymentInProgress" @@ -316,14 +318,16 @@ class SAPVirtualInstanceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) 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" -class SAPVirtualInstanceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the SAP Instance status. - """ + +class SAPVirtualInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the SAP Instance status.""" STARTING = "Starting" RUNNING = "Running" @@ -332,37 +336,38 @@ class SAPVirtualInstanceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum PARTIALLY_RUNNING = "PartiallyRunning" UNAVAILABLE = "Unavailable" -class SearchType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Search type - """ + +class SearchType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Search type.""" ELASTIC = "Elastic" -class SkuRestrictionReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU restriction reason code. - """ + +class SkuRestrictionReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU restriction reason code.""" NOT_SPECIFIED = "NotSpecified" QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class SkuRestrictionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU restriction type. - """ + +class SkuRestrictionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU restriction type.""" NOT_SPECIFIED = "NotSpecified" LOCATION = "Location" ZONE = "Zone" -class SkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scale type of the SKU capacity. - """ + +class SkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scale type of the SKU capacity.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. """ @@ -372,31 +377,31 @@ class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class WordpressVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Application version - """ + +class WordpressVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Application version.""" FIVE4_3 = "5.4.3" FIVE4_2 = "5.4.2" FIVE4_1 = "5.4.1" FIVE4 = "5.4" -class WorkloadKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates which kind of php workload this resource represent e.g WordPress - """ + +class WorkloadKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates which kind of php workload this resource represent e.g WordPress.""" WORD_PRESS = "WordPress" -class WorkloadMonitorActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Defines the action type of workload operation. - """ + +class WorkloadMonitorActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the action type of workload operation.""" NOT_SPECIFIED = "NotSpecified" INTERNAL = "Internal" -class WorkloadMonitorProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of provisioning of the SAP monitor. - """ + +class WorkloadMonitorProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of provisioning of the SAP monitor.""" ACCEPTED = "Accepted" CREATING = "Creating" diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py index 776a9a684ec2..517f5ecc331a 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/__init__.py @@ -18,16 +18,22 @@ from ._provider_instances_operations import ProviderInstancesOperations from ._skus_operations import SkusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PhpWorkloadsOperations', - 'WordpressInstancesOperations', - 'WorkloadsClientOperationsMixin', - 'SAPVirtualInstancesOperations', - 'SAPCentralInstancesOperations', - 'SAPDatabaseInstancesOperations', - 'SAPApplicationServerInstancesOperations', - 'Operations', - 'MonitorsOperations', - 'ProviderInstancesOperations', - 'SkusOperations', + "PhpWorkloadsOperations", + "WordpressInstancesOperations", + "WorkloadsClientOperationsMixin", + "SAPVirtualInstancesOperations", + "SAPCentralInstancesOperations", + "SAPDatabaseInstancesOperations", + "SAPApplicationServerInstancesOperations", + "Operations", + "MonitorsOperations", + "ProviderInstancesOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py index c3ad9d62562e..34a10bf50e45 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_monitors_operations.py @@ -6,318 +6,320 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_get_request( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, monitor_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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, monitor_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class MonitorsOperations(object): - """MonitorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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) + + +class MonitorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.WorkloadsClient`'s + :attr:`monitors` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.MonitorListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Monitor"]: """Gets a list of SAP monitors in the specified subscription. Gets a list of SAP monitors in the specified subscription. The operations returns various properties of each SAP monitor. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.MonitorListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Monitor or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -331,10 +333,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -345,58 +345,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/monitors"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.MonitorListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Monitor"]: """Gets a list of SAP monitors. Gets a list of SAP monitors in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.MonitorListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Monitor or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MonitorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitorListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,10 +421,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -424,57 +433,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> "_models.Monitor": + def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _models.Monitor: """Gets properties of a SAP monitor. Gets properties of a SAP monitor for the specified subscription, resource group, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Monitor, or the result of cls(response) + :return: Monitor or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.Monitor - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -482,89 +493,106 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore def _create_initial( - self, - resource_group_name: str, - monitor_name: str, - monitor_parameter: "_models.Monitor", - **kwargs: Any - ) -> "_models.Monitor": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] + self, resource_group_name: str, monitor_name: str, monitor_parameter: Union[_models.Monitor, IO], **kwargs: Any + ) -> _models.Monitor: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(monitor_parameter, 'Monitor') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitor_parameter, (IO, bytes)): + _content = monitor_parameter + else: + _json = self._serialize.body(monitor_parameter, "Monitor") + + request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, monitor_name: str, - monitor_parameter: "_models.Monitor", + monitor_parameter: _models.Monitor, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Monitor"]: + ) -> LROPoller[_models.Monitor]: """Creates a SAP monitor. Creates a SAP monitor for the specified subscription, resource group, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param monitor_parameter: Request body representing a SAP monitor. + :param monitor_parameter: Request body representing a SAP monitor. Required. :type monitor_parameter: ~azure.mgmt.workloads.models.Monitor + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -575,113 +603,192 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either Monitor or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.Monitor] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + monitor_name: str, + monitor_parameter: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Monitor]: + """Creates a SAP monitor. + + Creates a SAP monitor for the specified subscription, resource group, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param monitor_parameter: Request body representing a SAP monitor. Required. + :type monitor_parameter: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Monitor or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, monitor_name: str, monitor_parameter: Union[_models.Monitor, IO], **kwargs: Any + ) -> LROPoller[_models.Monitor]: + """Creates a SAP monitor. + + Creates a SAP monitor for the specified subscription, resource group, and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param monitor_parameter: Request body representing a SAP monitor. Is either a model type or a + IO type. Required. + :type monitor_parameter: ~azure.mgmt.workloads.models.Monitor or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Monitor or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.Monitor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, monitor_parameter=monitor_parameter, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: """Deletes a SAP monitor. Deletes a SAP monitor with the specified subscription, resource group, and SAP monitor name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -694,100 +801,184 @@ def begin_delete( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, monitor_name: str, - body: "_models.UpdateMonitorRequest", + body: _models.UpdateMonitorRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Monitor": + ) -> _models.Monitor: """Patches the Tags field of a SAP monitor. Patches the Tags field of a SAP monitor for the specified subscription, resource group, and SAP monitor name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param body: The Update SAP workload monitor request body. + :param body: The Update SAP workload monitor request body. Required. :type body: ~azure.mgmt.workloads.models.UpdateMonitorRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Monitor, or the result of cls(response) + :return: Monitor or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.Monitor - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + monitor_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Monitor: + """Patches the Tags field of a SAP monitor. + + Patches the Tags field of a SAP monitor for the specified subscription, resource group, and SAP + monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param body: The Update SAP workload monitor request body. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, monitor_name: str, body: Union[_models.UpdateMonitorRequest, IO], **kwargs: Any + ) -> _models.Monitor: + """Patches the Tags field of a SAP monitor. + + Patches the Tags field of a SAP monitor for the specified subscription, resource group, and SAP + monitor name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param body: The Update SAP workload monitor request body. Is either a model type or a IO type. + Required. + :type body: ~azure.mgmt.workloads.models.UpdateMonitorRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Monitor or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.Monitor + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Monitor"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(body, 'UpdateMonitorRequest') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Monitor] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "UpdateMonitorRequest") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -795,12 +986,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Monitor', pipeline_response) + deserialized = self._deserialize("Monitor", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py index 47cc4820beb7..b24f12b9e10d 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_operations.py @@ -6,110 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 .._vendor import _convert_request -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Workloads/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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.workloads.WorkloadsClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all the available API operations under this PR. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,10 +146,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Workloads/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Workloads/operations"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_patch.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/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-workloads/azure/mgmt/workloads/operations/_php_workloads_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_php_workloads_operations.py index c64555e444c5..aa14c7dca6b4 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_php_workloads_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_php_workloads_operations.py @@ -6,320 +6,326 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/phpWorkloads") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads", + ) # 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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, php_workload_name: str, + subscription_id: str, *, delete_infra: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if delete_infra is not None: - _query_parameters['delete-infra'] = _SERIALIZER.query("delete_infra", delete_infra, 'str', min_length=1) + _params["delete-infra"] = _SERIALIZER.query("delete_infra", delete_infra, "str", min_length=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PhpWorkloadsOperations(object): - """PhpWorkloadsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PhpWorkloadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.WorkloadsClient`'s + :attr:`php_workloads` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.PhpWorkloadResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.PhpWorkloadResource"]: """Lists PHP workload resources for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhpWorkloadResourceList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PhpWorkloadResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -333,10 +339,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -347,57 +351,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.PhpWorkloadResourceList"]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.PhpWorkloadResource"]: """Lists PHP workload 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhpWorkloadResourceList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PhpWorkloadResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -411,10 +427,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -425,54 +439,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any - ) -> "_models.PhpWorkloadResource": + def get(self, resource_group_name: str, php_workload_name: str, **kwargs: Any) -> _models.PhpWorkloadResource: """Gets the PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhpWorkloadResource, or the result of cls(response) + :return: PhpWorkloadResource or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,87 +496,179 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, php_workload_name: str, - php_workload_resource: "_models.PhpWorkloadResource", + php_workload_resource: Union[_models.PhpWorkloadResource, IO], **kwargs: Any - ) -> "_models.PhpWorkloadResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] + ) -> _models.PhpWorkloadResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(php_workload_resource, 'PhpWorkloadResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(php_workload_resource, (IO, bytes)): + _content = php_workload_resource + else: + _json = self._serialize.body(php_workload_resource, "PhpWorkloadResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + php_workload_resource: _models.PhpWorkloadResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhpWorkloadResource]: + """Create or updated PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param php_workload_resource: Resource create or update request payload. Required. + :type php_workload_resource: ~azure.mgmt.workloads.models.PhpWorkloadResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PhpWorkloadResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + php_workload_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhpWorkloadResource]: + """Create or updated PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param php_workload_resource: Resource create or update request payload. Required. + :type php_workload_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PhpWorkloadResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.PhpWorkloadResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, php_workload_name: str, - php_workload_resource: "_models.PhpWorkloadResource", + php_workload_resource: Union[_models.PhpWorkloadResource, IO], **kwargs: Any - ) -> LROPoller["_models.PhpWorkloadResource"]: + ) -> LROPoller[_models.PhpWorkloadResource]: """Create or updated PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str - :param php_workload_resource: Resource create or update request payload. - :type php_workload_resource: ~azure.mgmt.workloads.models.PhpWorkloadResource + :param php_workload_resource: Resource create or update request payload. Is either a model type + or a IO type. Required. + :type php_workload_resource: ~azure.mgmt.workloads.models.PhpWorkloadResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -572,100 +680,184 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either PhpWorkloadResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.PhpWorkloadResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, php_workload_name=php_workload_name, php_workload_resource=php_workload_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, php_workload_name: str, - resource_patch_request_body: "_models.PatchResourceRequestBody", + resource_patch_request_body: _models.PatchResourceRequestBody, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PhpWorkloadResource": + ) -> _models.PhpWorkloadResource: """Update PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str - :param resource_patch_request_body: Workload resource update data. + :param resource_patch_request_body: Workload resource update data. Required. :type resource_patch_request_body: ~azure.mgmt.workloads.models.PatchResourceRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhpWorkloadResource, or the result of cls(response) + :return: PhpWorkloadResource or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + php_workload_name: str, + resource_patch_request_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PhpWorkloadResource: + """Update PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param resource_patch_request_body: Workload resource update data. Required. + :type resource_patch_request_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhpWorkloadResource or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + php_workload_name: str, + resource_patch_request_body: Union[_models.PatchResourceRequestBody, IO], + **kwargs: Any + ) -> _models.PhpWorkloadResource: + """Update PHP workload resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param resource_patch_request_body: Workload resource update data. Is either a model type or a + IO type. Required. + :type resource_patch_request_body: ~azure.mgmt.workloads.models.PatchResourceRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhpWorkloadResource or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.PhpWorkloadResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhpWorkloadResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_patch_request_body, 'PatchResourceRequestBody') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhpWorkloadResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_patch_request_body, (IO, bytes)): + _content = resource_patch_request_body + else: + _json = self._serialize.body(resource_patch_request_body, "PatchResourceRequestBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -673,73 +865,73 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PhpWorkloadResource', pipeline_response) + deserialized = self._deserialize("PhpWorkloadResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - php_workload_name: str, - delete_infra: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, php_workload_name: str, delete_infra: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, php_workload_name=php_workload_name, - api_version=api_version, + subscription_id=self._config.subscription_id, delete_infra=delete_infra, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - php_workload_name: str, - delete_infra: Optional[str] = None, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, php_workload_name: str, delete_infra: Optional[str] = None, **kwargs: Any ) -> LROPoller[None]: """Delete PHP workload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :param delete_infra: Whether to delete infra along with workload resource. Default value is None. @@ -754,42 +946,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, php_workload_name=php_workload_name, delete_infra=delete_infra, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py index c301c686d0fb..75bd973cf7d4 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_provider_instances_operations.py @@ -6,261 +6,269 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +def build_list_request(resource_group_name: str, monitor_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any + resource_group_name: str, monitor_name: str, provider_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), - "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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, monitor_name: str, provider_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), - "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, monitor_name: str, provider_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), - "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "providerInstanceName": _SERIALIZER.url("provider_instance_name", provider_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ProviderInstancesOperations(object): - """ProviderInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ProviderInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.WorkloadsClient`'s + :attr:`provider_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - monitor_name: str, - **kwargs: Any - ) -> Iterable["_models.ProviderInstanceListResult"]: + def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> Iterable["_models.ProviderInstance"]: """Gets a list of provider instances in the specified SAP monitor. Gets a list of provider instances in the specified SAP monitor. The operations returns various properties of each provider instances. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderInstanceListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.ProviderInstanceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ProviderInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.ProviderInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstanceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstanceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - monitor_name=monitor_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -274,10 +282,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -288,61 +294,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any - ) -> "_models.ProviderInstance": + self, resource_group_name: str, monitor_name: str, provider_instance_name: str, **kwargs: Any + ) -> _models.ProviderInstance: """Gets properties of a provider instance. Gets properties of a provider instance for the specified subscription, resource group, SAP monitor name, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param provider_instance_name: Name of the provider instance. + :param provider_instance_name: Name of the provider instance. Required. :type provider_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderInstance, or the result of cls(response) + :return: ProviderInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.ProviderInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -350,72 +359,171 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore def _create_initial( self, resource_group_name: str, monitor_name: str, provider_instance_name: str, - provider_instance_parameter: "_models.ProviderInstance", + provider_instance_parameter: Union[_models.ProviderInstance, IO], **kwargs: Any - ) -> "_models.ProviderInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] + ) -> _models.ProviderInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(provider_instance_parameter, 'ProviderInstance') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(provider_instance_parameter, (IO, bytes)): + _content = provider_instance_parameter + else: + _json = self._serialize.body(provider_instance_parameter, "ProviderInstance") + + request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: _models.ProviderInstance, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProviderInstance]: + """Creates a provider instance. + + Creates a provider instance for the specified subscription, resource group, SAP monitor name, + and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. Required. + :type provider_instance_name: str + :param provider_instance_parameter: Request body representing a provider instance. Required. + :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ProviderInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.ProviderInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + monitor_name: str, + provider_instance_name: str, + provider_instance_parameter: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProviderInstance]: + """Creates a provider instance. + + Creates a provider instance for the specified subscription, resource group, SAP monitor name, + and resource name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Name of the SAP monitor resource. Required. + :type monitor_name: str + :param provider_instance_name: Name of the provider instance. Required. + :type provider_instance_name: str + :param provider_instance_parameter: Request body representing a provider instance. Required. + :type provider_instance_parameter: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ProviderInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.ProviderInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -423,22 +531,27 @@ def begin_create( resource_group_name: str, monitor_name: str, provider_instance_name: str, - provider_instance_parameter: "_models.ProviderInstance", + provider_instance_parameter: Union[_models.ProviderInstance, IO], **kwargs: Any - ) -> LROPoller["_models.ProviderInstance"]: + ) -> LROPoller[_models.ProviderInstance]: """Creates a provider instance. Creates a provider instance for the specified subscription, resource group, SAP monitor name, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param provider_instance_name: Name of the provider instance. + :param provider_instance_name: Name of the provider instance. Required. :type provider_instance_name: str - :param provider_instance_parameter: Request body representing a provider instance. - :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance + :param provider_instance_parameter: Request body representing a provider instance. Is either a + model type or a IO type. Required. + :type provider_instance_parameter: ~azure.mgmt.workloads.models.ProviderInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -450,120 +563,128 @@ def begin_create( :return: An instance of LROPoller that returns either ProviderInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.ProviderInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, provider_instance_parameter=provider_instance_parameter, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ProviderInstance', pipeline_response) + deserialized = self._deserialize("ProviderInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, monitor_name: str, provider_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - monitor_name: str, - provider_instance_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: + self, resource_group_name: str, monitor_name: str, provider_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: """Deletes a provider instance. Deletes a provider instance for the specified subscription, resource group, SAP monitor name, and resource name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param monitor_name: Name of the SAP monitor resource. + :param monitor_name: Name of the SAP monitor resource. Required. :type monitor_name: str - :param provider_instance_name: Name of the provider instance. + :param provider_instance_name: Name of the provider instance. Required. :type provider_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -576,45 +697,50 @@ def begin_delete( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, monitor_name=monitor_name, provider_instance_name=provider_instance_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_application_server_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_application_server_instances_operations.py index f89d32b33f4c..1ad8288eaafb 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_application_server_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_application_server_instances_operations.py @@ -6,300 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, 'str'), + "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"), + "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, 'str'), + "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"), + "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, 'str'), + "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"), + "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, 'str'), + "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"), + "applicationInstanceName": _SERIALIZER.url("application_instance_name", application_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SAPApplicationServerInstancesOperations(object): - """SAPApplicationServerInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.workloads.WorkloadsClient`'s + :attr:`sap_application_server_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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. + 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. + :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. + :param application_instance_name: The name of SAP Application Server instance resource. + Required. :type application_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPApplicationServerInstance, or the result of cls(response) + :return: SAPApplicationServerInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPApplicationServerInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,75 +324,176 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore def _create_initial( self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.SAPApplicationServerInstance"] = None, + body: Optional[Union[_models.SAPApplicationServerInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPApplicationServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] + ) -> _models.SAPApplicationServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPApplicationServerInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPApplicationServerInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # 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.workloads.models.SAPApplicationServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -383,20 +501,27 @@ def begin_create( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.SAPApplicationServerInstance"] = None, + body: Optional[Union[_models.SAPApplicationServerInstance, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPApplicationServerInstance"]: - """Puts the SAP Application Server Instance. :code:`
`:code:`
`This will be used by service - only. PUT by end user will return a Bad Request error. + ) -> 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. + :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. + :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 request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPApplicationServerInstance + :param body: The SAP Application Server Instance resource request body. Is either a model type + or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPApplicationServerInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -409,111 +534,218 @@ def begin_create( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore def _update_initial( self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.UpdateSAPApplicationInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPApplicationInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPApplicationServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] + ) -> _models.SAPApplicationServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPApplicationInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPApplicationInstanceRequest") + else: + _json = None - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + + @overload + def begin_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 + ) -> LROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server 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 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.workloads.models.UpdateSAPApplicationInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + application_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPApplicationServerInstance or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -521,19 +753,26 @@ def begin_update( resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, - body: Optional["_models.UpdateSAPApplicationInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPApplicationInstanceRequest, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPApplicationServerInstance"]: - """Puts the SAP Application Server Instance. + ) -> LROPoller[_models.SAPApplicationServerInstance]: + """Puts the SAP Application Server 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. + :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. + :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 request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPApplicationInstanceRequest + :param body: The SAP Application Server Instance resource request body. Is either a model type + or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPApplicationInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -546,118 +785,128 @@ def begin_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPApplicationServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPApplicationServerInstance', pipeline_response) + deserialized = self._deserialize("SAPApplicationServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - application_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - application_instance_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: - """Deletes the SAP Application Server Instance. :code:`
`:code:`
`This operation will be - used by service only. Delete by end user will return a Bad Request error. + self, resource_group_name: str, sap_virtual_instance_name: str, application_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """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. + :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. + :param application_instance_name: The name of SAP Application Server instance resource. + Required. :type application_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -670,100 +919,121 @@ def begin_delete( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances/{applicationInstanceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Iterable["_models.SAPApplicationServerInstanceList"]: - """Lists the SAP Application server Instances in an SVI. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPApplicationServerInstanceList or the result of + :return: An iterator like instance of either SAPApplicationServerInstance or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPApplicationServerInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPApplicationServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPApplicationServerInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPApplicationServerInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - sap_virtual_instance_name=sap_virtual_instance_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -777,10 +1047,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -791,8 +1059,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/applicationInstances"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_central_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_central_instances_operations.py index 73eafd5806ba..f73f2a535e86 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_central_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_central_instances_operations.py @@ -6,301 +6,316 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, 'str'), + "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"), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, 'str'), + "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"), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, 'str'), + "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"), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, 'str'), + "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"), + "centralInstanceName": _SERIALIZER.url("central_instance_name", central_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SAPCentralInstancesOperations(object): - """SAPCentralInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.workloads.WorkloadsClient`'s + :attr:`sap_central_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 Instance. + 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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPCentralServerInstance, or the result of cls(response) + :return: SAPCentralServerInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPCentralServerInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -308,75 +323,174 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore def _create_initial( self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.SAPCentralServerInstance"] = None, + body: Optional[Union[_models.SAPCentralServerInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPCentralServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] + ) -> _models.SAPCentralServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPCentralServerInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPCentralServerInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # 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.workloads.models.SAPCentralServerInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -384,21 +498,27 @@ def begin_create( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.SAPCentralServerInstance"] = None, + body: Optional[Union[_models.SAPCentralServerInstance, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPCentralServerInstance"]: - """Puts the SAP Central Instance. :code:`
`:code:`
`This will be used by service only. PUT - by end user will return a Bad Request error. + ) -> 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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPCentralServerInstance + :param body: The SAP Central Services Instance request body. Is either a model type or a IO + type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPCentralServerInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -410,111 +530,218 @@ def begin_create( :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore def _update_initial( self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.UpdateSAPCentralInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPCentralInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPCentralServerInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] + ) -> _models.SAPCentralServerInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPCentralInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPCentralInstanceRequest") + else: + _json = None - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + @overload + def begin_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 + ) -> LROPoller[_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.workloads.models.UpdateSAPCentralInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + central_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -522,20 +749,27 @@ def begin_update( resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, - body: Optional["_models.UpdateSAPCentralInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPCentralInstanceRequest, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPCentralServerInstance"]: - """Updates the SAP Central Instance. :code:`
`:code:`
`This can be used to update tags. + ) -> LROPoller[_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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPCentralInstanceRequest + :param body: The SAP Central Services Instance resource request body. Is either a model type or + a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPCentralInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -547,119 +781,130 @@ def begin_update( :return: An instance of LROPoller that returns either SAPCentralServerInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPCentralServerInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralServerInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralServerInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPCentralServerInstance', pipeline_response) + deserialized = self._deserialize("SAPCentralServerInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - central_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - central_instance_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: - """Deletes the SAP Central Instance. :code:`
`:code:`
`This will be used by service only. - Delete by end user will return a Bad Request error. + self, resource_group_name: str, sap_virtual_instance_name: str, central_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """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. + :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 Instance name string modeled as parameter for auto - generation to work correctly. + :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 :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -672,99 +917,121 @@ def begin_delete( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances/{centralInstanceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Iterable["_models.SAPCentralInstanceList"]: - """Lists the SAP Central Instances in an SVI. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPCentralInstanceList or the result of + :return: An iterator like instance of either SAPCentralServerInstance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPCentralInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPCentralServerInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPCentralInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPCentralInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - sap_virtual_instance_name=sap_virtual_instance_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -778,10 +1045,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,8 +1057,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/centralInstances"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_database_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_database_instances_operations.py index 68495b6fcbb4..c3d37e742b19 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_database_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_database_instances_operations.py @@ -6,301 +6,316 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, 'str'), + "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"), + "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, 'str'), + "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"), + "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, 'str'), + "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"), + "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), - "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, 'str'), + "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"), + "databaseInstanceName": _SERIALIZER.url("database_instance_name", database_instance_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SAPDatabaseInstancesOperations(object): - """SAPDatabaseInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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.workloads.WorkloadsClient`'s + :attr:`sap_database_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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. + 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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. :type database_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPDatabaseInstance, or the result of cls(response) + :return: SAPDatabaseInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPDatabaseInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -308,75 +323,176 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore def _create_initial( self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.SAPDatabaseInstance"] = None, + body: Optional[Union[_models.SAPDatabaseInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPDatabaseInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] + ) -> _models.SAPDatabaseInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPDatabaseInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPDatabaseInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # 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.workloads.models.SAPDatabaseInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -384,21 +500,28 @@ def begin_create( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.SAPDatabaseInstance"] = None, + body: Optional[Union[_models.SAPDatabaseInstance, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPDatabaseInstance"]: - """Puts the SAP Database Instance. :code:`
`:code:`
`This will be used by service only. PUT - by end user will return a Bad Request error. + ) -> 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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :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: The SAP Database Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPDatabaseInstance + :param body: Request body of Database resource of a SAP system. Is either a model type or a IO + type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPDatabaseInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -410,111 +533,216 @@ def begin_create( :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore def _update_initial( self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.UpdateSAPDatabaseInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPDatabaseInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPDatabaseInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] + ) -> _models.SAPDatabaseInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPDatabaseInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPDatabaseInstanceRequest") + else: + _json = None - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + + @overload + def begin_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 + ) -> LROPoller[_models.SAPDatabaseInstance]: + """Updates the Database 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.workloads.models.UpdateSAPDatabaseInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + database_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SAPDatabaseInstance]: + """Updates the Database 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -522,20 +750,26 @@ def begin_update( resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, - body: Optional["_models.UpdateSAPDatabaseInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPDatabaseInstanceRequest, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPDatabaseInstance"]: - """Puts the SAP Database Instance. + ) -> LROPoller[_models.SAPDatabaseInstance]: + """Updates the Database 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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :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: The SAP Database Server instance request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPDatabaseInstanceRequest + :param body: Database resource update request body. Is either a model type or a IO type. + Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPDatabaseInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -547,119 +781,129 @@ def begin_update( :return: An instance of LROPoller that returns either SAPDatabaseInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPDatabaseInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPDatabaseInstance', pipeline_response) + deserialized = self._deserialize("SAPDatabaseInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - database_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - database_instance_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: - """Deletes the SAP Database Instance. :code:`
`:code:`
`This will be used by service only. - Delete by end user will return a Bad Request error. + self, resource_group_name: str, sap_virtual_instance_name: str, database_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """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. + :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 Instance string modeled as parameter for auto - generation to work correctly. + :param database_instance_name: Database resource name string modeled as parameter for auto + generation to work correctly. Required. :type database_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -672,99 +916,119 @@ def begin_delete( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Iterable["_models.SAPDatabaseInstanceList"]: - """Lists the SAP Database Instances in an SVI. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPDatabaseInstanceList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPDatabaseInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SAPDatabaseInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPDatabaseInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDatabaseInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDatabaseInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - sap_virtual_instance_name=sap_virtual_instance_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -778,10 +1042,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,8 +1054,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_virtual_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_virtual_instances_operations.py index 99f0b81d4481..bb242e314a06 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_virtual_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_sap_virtual_instances_operations.py @@ -6,430 +6,511 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}") # pylint: disable=line-too-long + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _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( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}") # pylint: disable=line-too-long + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}") # pylint: disable=line-too-long + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _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_initial( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}") # pylint: disable=line-too-long + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-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 + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/sapVirtualInstances") + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any +def build_start_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - sap_virtual_instance_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_stop_request( + resource_group_name: str, sap_virtual_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - 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 + _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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _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(object): - """SAPVirtualInstancesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SAPVirtualInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.WorkloadsClient`'s + :attr:`sap_virtual_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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["_models.SAPVirtualInstance"] = None, + body: Optional[Union[_models.SAPVirtualInstance, IO]] = None, **kwargs: Any - ) -> "_models.SAPVirtualInstance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] + ) -> _models.SAPVirtualInstance: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'SAPVirtualInstance') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "SAPVirtualInstance") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # 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.workloads.models.SAPVirtualInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, sap_virtual_instance_name: str, - body: Optional["_models.SAPVirtualInstance"] = None, + body: Optional[Union[_models.SAPVirtualInstance, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.SAPVirtualInstance"]: - """Creates an Virtual Instance for SAP. + ) -> 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. + :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 request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.SAPVirtualInstance + :param body: Virtual Instance for SAP solutions resource request body. Is either a model type + or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.SAPVirtualInstance or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -441,93 +522,107 @@ def begin_create( :return: An instance of LROPoller that returns either SAPVirtualInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.SAPVirtualInstance] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> "_models.SAPVirtualInstance": - """Gets an Virtual Instance for SAP. + 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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPVirtualInstance, or the result of cls(response) + :return: SAPVirtualInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sap_virtual_instance_name=sap_virtual_instance_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,68 +630,149 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[_models.UpdateSAPVirtualInstanceRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _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.workloads.models.UpdateSAPVirtualInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, sap_virtual_instance_name: str, - body: Optional["_models.UpdateSAPVirtualInstanceRequest"] = None, + body: Optional[Union[_models.UpdateSAPVirtualInstanceRequest, IO]] = None, **kwargs: Any - ) -> "_models.SAPVirtualInstance": - """Updates an Virtual Instance for SAP. + ) -> _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. + :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 Update Virtual Instance for SAP request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.UpdateSAPVirtualInstanceRequest + :param body: Request body to update a Virtual Instance for SAP solutions resource. Is either a + model type or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.UpdateSAPVirtualInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPVirtualInstance, or the result of cls(response) + :return: SAPVirtualInstance or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPVirtualInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'UpdateSAPVirtualInstanceRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstance] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "UpdateSAPVirtualInstanceRequest") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -604,76 +780,80 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPVirtualInstance', pipeline_response) + deserialized = self._deserialize("SAPVirtualInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: - """Deletes an Virtual Instance for SAP. + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -686,93 +866,112 @@ def begin_delete( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.SAPVirtualInstanceList"]: - """Gets all Virtual Instances for SAP in a resource group. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPVirtualInstanceList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -786,10 +985,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -800,52 +997,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.SAPVirtualInstanceList"]: - """Gets all Virtual Instances for SAP in the subscription. + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SAPVirtualInstance"]: + """Gets all Virtual Instances for SAP solutions resources in a Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SAPVirtualInstanceList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstanceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SAPVirtualInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SAPVirtualInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPVirtualInstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPVirtualInstanceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -859,10 +1067,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -873,72 +1079,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/sapVirtualInstances"} # type: ignore def _start_initial( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + self, resource_group_name: str, sap_virtual_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + 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, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore @distributed_trace def begin_start( - self, - resource_group_name: str, - sap_virtual_instance_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: - """Starts the SAP System. + self, resource_group_name: str, sap_virtual_instance_name: str, **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. + :param sap_virtual_instance_name: The name of the Virtual Instances for SAP solutions resource. + Required. :type sap_virtual_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -951,120 +1160,228 @@ def begin_start( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/start"} # type: ignore def _stop_initial( self, resource_group_name: str, sap_virtual_instance_name: str, - body: Optional["_models.StopRequest"] = None, + body: Optional[Union[_models.StopRequest, IO]] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResult"]] + ) -> Optional[_models.OperationStatusResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'StopRequest') + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationStatusResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "StopRequest") + else: + _json = None - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._stop_initial.metadata['url'], + content=_content, + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # type: ignore + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # 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.workloads.models.StopRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop( + self, + resource_group_name: str, + sap_virtual_instance_name: str, + body: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_stop( self, resource_group_name: str, sap_virtual_instance_name: str, - body: Optional["_models.StopRequest"] = None, + body: Optional[Union[_models.StopRequest, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResult"]: - """Stops the SAP System. + ) -> 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. + :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 Instances for SAP stop request body. Default value is None. - :type body: ~azure.mgmt.workloads.models.StopRequest + :param body: The Virtual Instance for SAP solutions resource stop request body. Is either a + model type or a IO type. Default value is None. + :type body: ~azure.mgmt.workloads.models.StopRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1076,47 +1393,54 @@ def begin_stop( :return: An instance of LROPoller that returns either OperationStatusResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.OperationStatusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatusResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/stop"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_skus_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_skus_operations.py index 8f383ae2bc26..988a6fadb7b6 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_skus_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_skus_operations.py @@ -6,118 +6,139 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.WorkloadsClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.SkusListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuDefinition"]: """Lists all the available SKUs under this PR. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkusListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SkusListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.SkuDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SkusListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkusListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,10 +152,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +164,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/skus"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_wordpress_instances_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_wordpress_instances_operations.py index 6d99c1b5dc38..f4a1465856f5 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_wordpress_instances_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_wordpress_instances_operations.py @@ -6,253 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any + resource_group_name: str, php_workload_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default", + ) # 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), - "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, 'str'), + "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 + ), + "phpWorkloadName": _SERIALIZER.url("php_workload_name", php_workload_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WordpressInstancesOperations(object): - """WordpressInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.workloads.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WordpressInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.workloads.WorkloadsClient`'s + :attr:`wordpress_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any - ) -> Iterable["_models.WordpressInstanceResourceList"]: + self, resource_group_name: str, php_workload_name: str, **kwargs: Any + ) -> Iterable["_models.WordpressInstanceResource"]: """Lists WordPress instance resources under a phpWorkload resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WordpressInstanceResourceList or the result of + :return: An iterator like instance of either WordpressInstanceResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.WordpressInstanceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.workloads.models.WordpressInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResourceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResourceList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - php_workload_name=php_workload_name, - api_version=api_version, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,10 +281,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,54 +293,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any - ) -> "_models.WordpressInstanceResource": + def get(self, resource_group_name: str, php_workload_name: str, **kwargs: Any) -> _models.WordpressInstanceResource: """Gets the WordPress instance resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WordpressInstanceResource, or the result of cls(response) + :return: WordpressInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.WordpressInstanceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,87 +350,179 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, php_workload_name: str, - wordpress_instance_resource: "_models.WordpressInstanceResource", + wordpress_instance_resource: Union[_models.WordpressInstanceResource, IO], **kwargs: Any - ) -> "_models.WordpressInstanceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResource"] + ) -> _models.WordpressInstanceResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(wordpress_instance_resource, 'WordpressInstanceResource') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(wordpress_instance_resource, (IO, bytes)): + _content = wordpress_instance_resource + else: + _json = self._serialize.body(wordpress_instance_resource, "WordpressInstanceResource") + + request = build_create_or_update_request( resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + wordpress_instance_resource: _models.WordpressInstanceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WordpressInstanceResource]: + """Create or updated WordPress instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param wordpress_instance_resource: Resource create or update request payload. Required. + :type wordpress_instance_resource: ~azure.mgmt.workloads.models.WordpressInstanceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WordpressInstanceResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.WordpressInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + php_workload_name: str, + wordpress_instance_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WordpressInstanceResource]: + """Create or updated WordPress instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param php_workload_name: Php workload name. Required. + :type php_workload_name: str + :param wordpress_instance_resource: Resource create or update request payload. Required. + :type wordpress_instance_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WordpressInstanceResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.WordpressInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, php_workload_name: str, - wordpress_instance_resource: "_models.WordpressInstanceResource", + wordpress_instance_resource: Union[_models.WordpressInstanceResource, IO], **kwargs: Any - ) -> LROPoller["_models.WordpressInstanceResource"]: + ) -> LROPoller[_models.WordpressInstanceResource]: """Create or updated WordPress instance resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str - :param wordpress_instance_resource: Resource create or update request payload. - :type wordpress_instance_resource: ~azure.mgmt.workloads.models.WordpressInstanceResource + :param wordpress_instance_resource: Resource create or update request payload. Is either a + model type or a IO type. Required. + :type wordpress_instance_resource: ~azure.mgmt.workloads.models.WordpressInstanceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -427,93 +534,106 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either WordpressInstanceResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.workloads.models.WordpressInstanceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WordpressInstanceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WordpressInstanceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, php_workload_name=php_workload_name, wordpress_instance_resource=wordpress_instance_resource, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WordpressInstanceResource', pipeline_response) + deserialized = self._deserialize("WordpressInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - php_workload_name: str, - **kwargs: Any + self, resource_group_name: str, php_workload_name: str, **kwargs: Any ) -> None: """Delete WordPress instance resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param php_workload_name: Php workload name. + :param php_workload_name: Php workload name. Required. :type php_workload_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, php_workload_name=php_workload_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -524,5 +644,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/phpWorkloads/{phpWorkloadName}/wordpressInstances/default"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_workloads_client_operations.py b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_workloads_client_operations.py index 74346da4a818..0f8a0ebc96b3 100644 --- a/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_workloads_client_operations.py +++ b/sdk/workloads/azure-mgmt-workloads/azure/mgmt/workloads/operations/_workloads_client_operations.py @@ -6,244 +6,294 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +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 .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import WorkloadsClientMixinABC, _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_sap_sizing_recommendations_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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 + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_sap_supported_sku_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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 + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_sap_disk_configurations_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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 + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_sap_availability_zone_details_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _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(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 = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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 + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WorkloadsClientOperationsMixin(object): - @distributed_trace +class WorkloadsClientOperationsMixin(WorkloadsClientMixinABC): + @overload def sap_sizing_recommendations( self, location: str, - sap_sizing_recommendation: Optional["_models.SAPSizingRecommendationRequest"] = None, + sap_sizing_recommendation: Optional[_models.SAPSizingRecommendationRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPSizingRecommendationResult": - """Get SAP sizing recommendations. + ) -> _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. + :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.workloads.models.SAPSizingRecommendationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPSizingRecommendationResult, or the result of cls(response) + :return: SAPSizingRecommendationResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPSizingRecommendationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPSizingRecommendationResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPSizingRecommendationResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace + def sap_sizing_recommendations( + self, + location: str, + sap_sizing_recommendation: Optional[Union[_models.SAPSizingRecommendationRequest, IO]] = None, + **kwargs: Any + ) -> _models.SAPSizingRecommendationResult: + """Get SAP sizing recommendations by providing input SAPS for application tier and memory required + for database tier. - if sap_sizing_recommendation is not None: - _json = self._serialize.body(sap_sizing_recommendation, 'SAPSizingRecommendationRequest') + :param location: The name of Azure region. Required. + :type location: str + :param sap_sizing_recommendation: SAP Sizing Recommendation Request body. Is either a model + type or a IO type. Default value is None. + :type sap_sizing_recommendation: ~azure.mgmt.workloads.models.SAPSizingRecommendationRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSizingRecommendationResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPSizingRecommendationResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_sizing_recommendation, (IO, bytes)): + _content = sap_sizing_recommendation else: - _json = None + if sap_sizing_recommendation is not None: + _json = self._serialize.body(sap_sizing_recommendation, "SAPSizingRecommendationRequest") + else: + _json = None request = build_sap_sizing_recommendations_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_sizing_recommendations.metadata['url'], + content=_content, + template_url=self.sap_sizing_recommendations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,64 +301,131 @@ def sap_sizing_recommendations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPSizingRecommendationResult', pipeline_response) + deserialized = self._deserialize("SAPSizingRecommendationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_sizing_recommendations.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSizingRecommendations"} # type: ignore + sap_sizing_recommendations.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSizingRecommendations"} # type: ignore - - @distributed_trace + @overload def sap_supported_sku( self, location: str, - sap_supported_sku: Optional["_models.SAPSupportedSkusRequest"] = None, + sap_supported_sku: Optional[_models.SAPSupportedSkusRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPSupportedResourceSkusResult": - """Get SAP supported SKUs. + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. - :param location: The name of Azure region. + :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.workloads.models.SAPSupportedSkusRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPSupportedResourceSkusResult, or the result of cls(response) + :return: SAPSupportedResourceSkusResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPSupportedResourceSkusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPSupportedResourceSkusResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPSupportedResourceSkusResult: + """Get a list of SAP supported SKUs for ASCS, Application and Database tier. - if sap_supported_sku is not None: - _json = self._serialize.body(sap_supported_sku, 'SAPSupportedSkusRequest') + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPSupportedResourceSkusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def sap_supported_sku( + self, + location: str, + sap_supported_sku: Optional[Union[_models.SAPSupportedSkusRequest, IO]] = 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 model type or a IO type. + Default value is None. + :type sap_supported_sku: ~azure.mgmt.workloads.models.SAPSupportedSkusRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPSupportedResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPSupportedResourceSkusResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_supported_sku, (IO, bytes)): + _content = sap_supported_sku else: - _json = None + if sap_supported_sku is not None: + _json = self._serialize.body(sap_supported_sku, "SAPSupportedSkusRequest") + else: + _json = None request = build_sap_supported_sku_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_supported_sku.metadata['url'], + content=_content, + template_url=self.sap_supported_sku.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -316,64 +433,131 @@ def sap_supported_sku( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPSupportedResourceSkusResult', pipeline_response) + deserialized = self._deserialize("SAPSupportedResourceSkusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_supported_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSapSupportedSku"} # type: ignore - + sap_supported_sku.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getSapSupportedSku"} # type: ignore - @distributed_trace + @overload def sap_disk_configurations( self, location: str, - sap_disk_configurations: Optional["_models.SAPDiskConfigurationsRequest"] = None, + sap_disk_configurations: Optional[_models.SAPDiskConfigurationsRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPDiskConfigurationsResult": - """Get SAP Disk Configurations. + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. - :param location: The name of Azure region. + :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.workloads.models.SAPDiskConfigurationsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPDiskConfigurationsResult, or the result of cls(response) + :return: SAPDiskConfigurationsResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPDiskConfigurationsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPDiskConfigurationsResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SAPDiskConfigurationsResult: + """Get the SAP Disk Configuration Layout prod/non-prod SAP System. - if sap_disk_configurations is not None: - _json = self._serialize.body(sap_disk_configurations, 'SAPDiskConfigurationsRequest') + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPDiskConfigurationsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def sap_disk_configurations( + self, + location: str, + sap_disk_configurations: Optional[Union[_models.SAPDiskConfigurationsRequest, IO]] = 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 model type or + a IO type. Default value is None. + :type sap_disk_configurations: ~azure.mgmt.workloads.models.SAPDiskConfigurationsRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPDiskConfigurationsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPDiskConfigurationsResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_disk_configurations, (IO, bytes)): + _content = sap_disk_configurations else: - _json = None + if sap_disk_configurations is not None: + _json = self._serialize.body(sap_disk_configurations, "SAPDiskConfigurationsRequest") + else: + _json = None request = build_sap_disk_configurations_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_disk_configurations.metadata['url'], + content=_content, + template_url=self.sap_disk_configurations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,66 +565,135 @@ def sap_disk_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPDiskConfigurationsResult', pipeline_response) + deserialized = self._deserialize("SAPDiskConfigurationsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_disk_configurations.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getDiskConfigurations"} # type: ignore - + sap_disk_configurations.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getDiskConfigurations"} # type: ignore - @distributed_trace + @overload def sap_availability_zone_details( self, location: str, - sap_availability_zone_details: Optional["_models.SAPAvailabilityZoneDetailsRequest"] = None, + sap_availability_zone_details: Optional[_models.SAPAvailabilityZoneDetailsRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SAPAvailabilityZoneDetailsResult": - """Get SAP Availability Zone Details. + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. - :param location: The name of Azure 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.workloads.models.SAPAvailabilityZoneDetailsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SAPAvailabilityZoneDetailsResult, or the result of cls(response) + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) :rtype: ~azure.mgmt.workloads.models.SAPAvailabilityZoneDetailsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[IO] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.models.SAPAvailabilityZoneDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SAPAvailabilityZoneDetailsResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace + def sap_availability_zone_details( + self, + location: str, + sap_availability_zone_details: Optional[Union[_models.SAPAvailabilityZoneDetailsRequest, IO]] = None, + **kwargs: Any + ) -> _models.SAPAvailabilityZoneDetailsResult: + """Get the recommended SAP Availability Zone Pair Details for your region. - if sap_availability_zone_details is not None: - _json = self._serialize.body(sap_availability_zone_details, 'SAPAvailabilityZoneDetailsRequest') + :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 + model type or a IO type. Default value is None. + :type sap_availability_zone_details: + ~azure.mgmt.workloads.models.SAPAvailabilityZoneDetailsRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SAPAvailabilityZoneDetailsResult or the result of cls(response) + :rtype: ~azure.mgmt.workloads.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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2021-12-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SAPAvailabilityZoneDetailsResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sap_availability_zone_details, (IO, bytes)): + _content = sap_availability_zone_details else: - _json = None + 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( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sap_availability_zone_details.metadata['url'], + content=_content, + template_url=self.sap_availability_zone_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,12 +701,11 @@ def sap_availability_zone_details( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SAPAvailabilityZoneDetailsResult', pipeline_response) + deserialized = self._deserialize("SAPAvailabilityZoneDetailsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - sap_availability_zone_details.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails"} # type: ignore - + sap_availability_zone_details.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Workloads/locations/{location}/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails"} # type: ignore diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_db2_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_db2_provider.py new file mode 100644 index 000000000000..474ab90da3d4 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_db2_provider.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_a_db2_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_create( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + provider_instance_parameter={ + "properties": { + "providerSettings": { + "dbName": "dbName", + "dbPassword": "password", + "dbPasswordUri": "", + "dbPort": "dbPort", + "dbUsername": "username", + "hostname": "hostname", + "providerType": "Db2", + "sapSid": "SID", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/Db2ProviderInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_ms_sql_server_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_ms_sql_server_provider.py new file mode 100644 index 000000000000..894de4e51f69 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_ms_sql_server_provider.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_a_ms_sql_server_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_create( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + provider_instance_parameter={ + "properties": { + "providerSettings": { + "dbPassword": "****", + "dbPasswordUri": "", + "dbPort": "5912", + "dbUsername": "user", + "hostname": "hostname", + "providerType": "MsSqlServer", + "sapSid": "sid", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/MsSqlServerProviderInstance_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_os_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_os_provider.py new file mode 100644 index 000000000000..db4da2310b46 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_os_provider.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_a_os_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_create( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + provider_instance_parameter={ + "properties": { + "providerSettings": {"prometheusUrl": "http://192.168.0.0:9090/metrics", "providerType": "PrometheusOS"} + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/PrometheusOSProviderInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_prometheus_ha_cluster_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_prometheus_ha_cluster_provider.py new file mode 100644 index 000000000000..29bcdbd42cc6 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_prometheus_ha_cluster_provider.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_a_prometheus_ha_cluster_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_create( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + provider_instance_parameter={ + "properties": { + "providerSettings": { + "clusterName": "clusterName", + "hostname": "hostname", + "prometheusUrl": "http://192.168.0.0:9090/metrics", + "providerType": "PrometheusHaCluster", + "sid": "sid", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_sap_monitor_hana_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_sap_monitor_hana_provider.py new file mode 100644 index 000000000000..0d677a3348af --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_sap_monitor_hana_provider.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_a_sap_monitor_hana_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_create( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + provider_instance_parameter={ + "properties": { + "providerSettings": { + "dbName": "db", + "dbPassword": "****", + "dbPasswordUri": "", + "dbSslCertificateUri": "https://storageaccount.blob.core.windows.net/containername/filename", + "dbUsername": "user", + "hostname": "name", + "instanceNumber": "00", + "providerType": "SapHana", + "sqlPort": "0000", + "sslHostNameInCertificate": "xyz.domain.com", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/ProviderInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_sap_monitor_net_weaver_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_sap_monitor_net_weaver_provider.py new file mode 100644 index 000000000000..d14d2c940727 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_a_sap_monitor_net_weaver_provider.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_a_sap_monitor_net_weaver_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_create( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + provider_instance_parameter={ + "properties": { + "providerSettings": { + "providerType": "SapNetWeaver", + "sapClientId": "111", + "sapHostFileEntries": ["127.0.0.1 name fqdn"], + "sapHostname": "name", + "sapInstanceNr": "00", + "sapPassword": "****", + "sapPasswordUri": "", + "sapPortNumber": "1234", + "sapSid": "SID", + "sapSslCertificateUri": "https://storageaccount.blob.core.windows.net/containername/filename", + "sapUsername": "username", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/NetWeaverProviderInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_distributed_system.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_distributed_system.py new file mode 100644 index 000000000000..6cc286a3ac99 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_distributed_system.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_only_for_distributed_system.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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_ha_system_with_availability_set.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_ha_system_with_availability_set.py new file mode 100644 index 000000000000..2d9f485fd48a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_ha_system_with_availability_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_only_for_ha_system_with_availability_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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_ha_system_with_availability_zone.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_ha_system_with_availability_zone.py new file mode 100644 index 000000000000..823cdd4ac077 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_ha_system_with_availability_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_only_for_ha_system_with_availability_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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_single_server_system.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_single_server_system.py new file mode 100644 index 000000000000..c2b2186ec12c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_only_for_single_server_system.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_only_for_single_server_system.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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_distributed_system_(_recommended).py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_distributed_system_(_recommended).py new file mode 100644 index 000000000000..cb49288446a7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_distributed_system_(_recommended).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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_with_os_configuration_for_distributed_system_(_recommended).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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_ha_system_with_availability_set_(_recommended).py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_ha_system_with_availability_set_(_recommended).py new file mode 100644 index 000000000000..7364bbd2cceb --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_ha_system_with_availability_set_(_recommended).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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_with_os_configuration_for_ha_system_with_availability_set_(_recommended).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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_ha_system_with_availability_zone_(_recommended).py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_ha_system_with_availability_zone_(_recommended).py new file mode 100644 index 000000000000..467479f05d0c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_ha_system_with_availability_zone_(_recommended).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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_with_os_configuration_for_ha_system_with_availability_zone_(_recommended).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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_single_server_system_(_recommended).py b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_single_server_system_(_recommended).py new file mode 100644 index 000000000000..802520843049 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/create_infrastructure_with_os_configuration_for_single_server_system_(_recommended).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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python create_infrastructure_with_os_configuration_for_single_server_system_(_recommended).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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_WithOSConfig_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/delete_tags_field_of_a_sap_monitor.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/delete_tags_field_of_a_sap_monitor.py new file mode 100644 index 000000000000..1128ec7f6a46 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/delete_tags_field_of_a_sap_monitor.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python delete_tags_field_of_a_sap_monitor.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitors.update( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + body={"identity": {"type": "None"}, "tags": {}}, + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/monitors_PatchTags_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/deletes_a_sap_monitor.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/deletes_a_sap_monitor.py new file mode 100644 index 000000000000..b641d727fc75 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/deletes_a_sap_monitor.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python deletes_a_sap_monitor.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitors.begin_delete( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/monitors_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/deletes_a_sap_monitor_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/deletes_a_sap_monitor_provider.py new file mode 100644 index 000000000000..021d01fe0bb0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/deletes_a_sap_monitor_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python deletes_a_sap_monitor_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.begin_delete( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/ProviderInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_a_distributed_system.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_a_distributed_system.py new file mode 100644 index 000000000000..c76b0e7c61da --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_a_distributed_system.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python detect_sap_software_installation_on_a_distributed_system.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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_a_single_server_system.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_a_single_server_system.py new file mode 100644 index 000000000000..364c6ac0f07f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_a_single_server_system.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python detect_sap_software_installation_on_a_single_server_system.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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_an_ha_system_with_availability_set.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_an_ha_system_with_availability_set.py new file mode 100644 index 000000000000..fbe3bb20361b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_an_ha_system_with_availability_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python detect_sap_software_installation_on_an_ha_system_with_availability_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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_an_ha_system_with_availability_zone.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_an_ha_system_with_availability_zone.py new file mode 100644 index 000000000000..0cfb06e3f60e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/detect_sap_software_installation_on_an_ha_system_with_availability_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python detect_sap_software_installation_on_an_ha_system_with_availability_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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_DetectInstallation_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_db2_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_db2_provider.py new file mode 100644 index 000000000000..6939fbfc07b3 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_db2_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_db2_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/Db2ProviderInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_ms_sql_server_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_ms_sql_server_provider.py new file mode 100644 index 000000000000..efeb1b40e451 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_ms_sql_server_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_ms_sql_server_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_os_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_os_provider.py new file mode 100644 index 000000000000..dd1c80e32ebc --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_os_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_os_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_prometheus_ha_cluster_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_prometheus_ha_cluster_provider.py new file mode 100644 index 000000000000..817b88320997 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_prometheus_ha_cluster_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_prometheus_ha_cluster_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor.py new file mode 100644 index 000000000000..758a83b09db0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_sap_monitor.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitors.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/monitors_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor_hana_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor_hana_provider.py new file mode 100644 index 000000000000..999ce1da8ca0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor_hana_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_sap_monitor_hana_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/ProviderInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor_net_weaver_provider.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor_net_weaver_provider.py new file mode 100644 index 000000000000..ff5fdb086654 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/get_properties_of_a_sap_monitor_net_weaver_provider.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python get_properties_of_a_sap_monitor_net_weaver_provider.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.get( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + provider_instance_name="myProviderInstance", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/NetWeaverProviderInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/install_sap_software_on_distributed_system.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/install_sap_software_on_distributed_system.py new file mode 100644 index 000000000000..cac0e5356614 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/install_sap_software_on_distributed_system.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python install_sap_software_on_distributed_system.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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Install_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/install_sap_software_on_single_server_system.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/install_sap_software_on_single_server_system.py new file mode 100644 index 000000000000..1a34fa038e3a --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/install_sap_software_on_single_server_system.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python install_sap_software_on_single_server_system.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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Install_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_in_a_resource_group.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_in_a_resource_group.py new file mode 100644 index 000000000000..e387110a1233 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_in_a_resource_group.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python list_all_sap_monitors_in_a_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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitors.list_by_resource_group( + resource_group_name="example-rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/monitors_ListByRG.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_in_a_subscription.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_in_a_subscription.py new file mode 100644 index 000000000000..283bc8ad0866 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_in_a_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python list_all_sap_monitors_in_a_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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitors.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/monitors_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_providers_in_a_subscription.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_providers_in_a_subscription.py new file mode 100644 index 000000000000..4d1b325e3067 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/list_all_sap_monitors_providers_in_a_subscription.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python list_all_sap_monitors_providers_in_a_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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.provider_instances.list( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/ProviderInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/operations.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/operations.py new file mode 100644 index 000000000000..b8c4b35c4bfb --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/operations.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/Operations_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/register_existing_sap_system_as_virtual_instance_for_sap_solutions..py b/sdk/workloads/azure-mgmt-workloads/generated_samples/register_existing_sap_system_as_virtual_instance_for_sap_solutions..py new file mode 100644 index 000000000000..de2bc25d6e8c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/register_existing_sap_system_as_virtual_instance_for_sap_solutions..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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python register_existing_sap_system_as_virtual_instance_for_sap_solutions..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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Create_Discover.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_create.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_create.py new file mode 100644 index 000000000000..ebf680b7aab9 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_create.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPApplicationServerInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_delete.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_delete.py new file mode 100644 index 000000000000..456d14959ba2 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.begin_delete( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPApplicationServerInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_get.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_get.py new file mode 100644 index 000000000000..bd5f6393b759 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPApplicationServerInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_list.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_list.py new file mode 100644 index 000000000000..dad88556390e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_list.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPApplicationServerInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_update.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_instances_update.py new file mode 100644 index 000000000000..46270ab2298b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_application_server_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_application_server_instances.begin_update( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPApplicationServerInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_availability_zone_details_eastus.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_availability_zone_details_eastus.py new file mode 100644 index 000000000000..131c96c30eab --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_availability_zone_details_eastus.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPAvailabilityZoneDetails_eastus.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_availability_zone_details_northeurope.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_availability_zone_details_northeurope.py new file mode 100644 index 000000000000..3b18f535756e --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_availability_zone_details_northeurope.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPAvailabilityZoneDetails_northeurope.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_create.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_create.py new file mode 100644 index 000000000000..524241615232 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_create.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPCentralInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_delete.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_delete.py new file mode 100644 index 000000000000..20d13349c92d --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.begin_delete( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPCentralInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_get.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_get.py new file mode 100644 index 000000000000..0543b8a215cd --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPCentralInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_list.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_list.py new file mode 100644 index 000000000000..0cd9d3bc4c17 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_list.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPCentralInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_update.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_instances_update.py new file mode 100644 index 000000000000..006cbe58fbc0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_central_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_central_instances.begin_update( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPCentralInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_create.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_create.py new file mode 100644 index 000000000000..66909457ec27 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_create.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDatabaseInstances_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_delete.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_delete.py new file mode 100644 index 000000000000..115f1c28c309 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.begin_delete( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDatabaseInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_get.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_get.py new file mode 100644 index 000000000000..d37dc3ca4f90 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDatabaseInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_list.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_list.py new file mode 100644 index 000000000000..1e9b35810b79 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_list.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDatabaseInstances_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_update.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_instances_update.py new file mode 100644 index 000000000000..dd8b70b797b3 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_database_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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_database_instances.begin_update( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDatabaseInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_disk_configurations_non_prod.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_disk_configurations_non_prod.py new file mode 100644 index 000000000000..1bb38627feb7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_disk_configurations_non_prod.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDiskConfigurations_NonProd.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_disk_configurations_prod.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_disk_configurations_prod.py new file mode 100644 index 000000000000..36b3fb59117c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_disk_configurations_prod.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPDiskConfigurations_Prod.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed.py new file mode 100644 index 000000000000..25e02449b542 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed_ha_av_set.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed_ha_av_set.py new file mode 100644 index 000000000000..cc72a83dd5a0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed_ha_av_set.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python sap_sizing_recommendations_s4_hana_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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_HA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed_ha_av_zone.py new file mode 100644 index 000000000000..4f345cbb3e87 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_distributed_ha_av_zone.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python sap_sizing_recommendations_s4_hana_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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_HA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_single_server.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_single_server.py new file mode 100644 index 000000000000..0e0e6dfa461f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_sizing_recommendations_s4_hana_single_server.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSizingRecommendations_S4HANA_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed.py new file mode 100644 index 000000000000..0f77bb216f4f --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_Distributed.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed_ha_av_set.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed_ha_av_set.py new file mode 100644 index 000000000000..aa95ea0eea13 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed_ha_av_set.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_DistributedHA_AvSet.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed_ha_av_zone.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed_ha_av_zone.py new file mode 100644 index 000000000000..240bfc16a0d0 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_distributed_ha_av_zone.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_DistributedHA_AvZone.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_single_server.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_single_server.py new file mode 100644 index 000000000000..39c3beeaaf24 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_supported_skus_single_server.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPSupportedSkus_SingleServer.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_delete.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_delete.py new file mode 100644 index 000000000000..1a541c693bc4 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="6d875e77-e412-4d7d-9af4-8895278b4443", + ) + + response = client.sap_virtual_instances.begin_delete( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ).result() + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_get.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_get.py new file mode 100644 index 000000000000..ae49c19da633 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_get.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_list_by_resource_group.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_list_by_resource_group.py new file mode 100644 index 000000000000..7c5a2792fcd7 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_list_by_resource_group.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_list_by_subscription.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_list_by_subscription.py new file mode 100644 index 000000000000..d9b14667ec0c --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_start.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_start.py new file mode 100644 index 000000000000..2a8bde724127 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_start.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Start.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_stop.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_stop.py new file mode 100644 index 000000000000..5a7edc38ad15 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_stop.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + 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/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Stop.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_update.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_update.py new file mode 100644 index 000000000000..6ff47e40ead8 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/sap_virtual_instances_update.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# 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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.sap_virtual_instances.update( + resource_group_name="test-rg", + sap_virtual_instance_name="X00", + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/sapvirtualinstances/SAPVirtualInstances_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/skus.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/skus.py new file mode 100644 index 000000000000..d656ef077fed --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/skus.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python skus.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.skus.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/Skus_List.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/update_tags_field_of_a_sap_monitor.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/update_tags_field_of_a_sap_monitor.py new file mode 100644 index 000000000000..505d5f093e7b --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/update_tags_field_of_a_sap_monitor.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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python update_tags_field_of_a_sap_monitor.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitors.update( + resource_group_name="myResourceGroup", + monitor_name="mySapMonitor", + body={"identity": {"type": "None"}, "tags": {"testkey": "testvalue"}}, + ) + print(response) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/workloadmonitor/monitors_PatchTags.json +if __name__ == "__main__": + main() diff --git a/sdk/workloads/azure-mgmt-workloads/generated_samples/workloads.py b/sdk/workloads/azure-mgmt-workloads/generated_samples/workloads.py new file mode 100644 index 000000000000..8f1f2398f959 --- /dev/null +++ b/sdk/workloads/azure-mgmt-workloads/generated_samples/workloads.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.workloads import WorkloadsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-workloads +# USAGE + python workloads.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 = WorkloadsClient( + credential=DefaultAzureCredential(), + subscription_id="8e17e36c-42e9-4cd5-a078-7b44883414e0", + ) + + response = client.php_workloads.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/workloads/resource-manager/Microsoft.Workloads/preview/2021-12-01-preview/examples/phpworkloads/PhpWorkloads_ListBySubscription.json +if __name__ == "__main__": + main()